Docker. Symlink INSIDE context not working - docker

I've simplified setup for demonstration purposes, but I don't understand why this issue happens. What do I miss.
Project folder content
current -> releases/21
releases
inside releases/21 project with docker-compose.yml is located.
Here is the abridged version of my docker-compose.yml
version: '3'
services:
app:
container_name: app
build:
context: ../
dockerfile: ./current/docker/app.docker
Of course, app.docker is there.
And still I receive this error
ERROR: Cannot locate specified Dockerfile: current/docker/app.docker
After running docker-compose up -d in the <project_folder>/current.

It works with an absolute path.
Something like this will work, but I still feel, that it's not a solution
version: '3'
services:
app:
container_name: app
build:
context: /var/www/<project-name>
dockerfile: ./current/docker/app.docker

Related

Docker-compose build: How to build an image for production and copy an app code to image?

https://docs.docker.com/compose/production/
Removing any volume bindings for application code, so that code stays
inside the container and can’t be changed from outside
I'd like to build image for production with my app code.
I have a file docker-compose-prod.yml
version: '3'
services:
------
nginx:
build:
context: ./docker/nginx
image: my_nginx:v1
ports:
- 80:80
volumes:
- ./docker/app:/var/www/html
depends_on:
- php
------
The code of my app located in ./docker/app.
The Dockerfile located in ./docker/nginx and I can't with command COPY to copy an app code outside /docker/nginx folder.
When I run a build command I get an image without app contend in /var/www/html:
docker-compose -f docker-compose-prod.yml build
How to build an image in this case with my an app code?
You could pass the dockerfile in the build argument: https://docs.docker.com/compose/compose-file/#dockerfile
This way, I think that you can change your app context to be ./docker, and in the Dockerfile, copy the app folder to /var/www/html. This way, you no longer have to specify a volume when starting the app.
Correct config looks like:
version: '3'
services:
------
nginx:
build:
context: ./docker
dockerfile: nginx/Dockerfile-prod
image: my_nginx:v1
ports:
- 80:80
------
And the Dockerfile-prod in /docker/nginx
...
COPY ./app /var/www/html
...

how to solve docker error of "Cannot locate specified Dockerfile: Dockerfile"

I'm following this link to making a docker-compose.yml file but it will giving me the same issue does not find the docker file while I'm mentioning that in the docker-compose.yml see my code:-
version: '2'
services:
web:
build: .
ports:
- "8000:8000"
users:
build:
context: ./users
dockerfile: Dockerfile
image: cinema/movies
container_name: cinema-movies
environment:
VIRTUAL_HOST: movies.local
And docker-compose.yml file is in the bkapiv folder the folder structure is :-
bkapiv(Folder)------users(Folder)
| |
| ------Dockerfile
|
---------docker-compose.yml
How will I resolve my issue that I will run my first api on local using docker.
web:
build: .
I think error throwing from web container, commented out the users and run the docker-compose, you need a Dockerfile in web too. Also try other way around. The you can understand which container produce the error. Because users looks fine for me according to your folder structure. Plus you have an extra space in services:
The problem is in the web service, you specified that it should build a Dockerfile in your current dir but there is no Dockerfile there.

Are docker environment variables shared between containers?

Newbie here. I created an empty solution, added WebApplication1 and WebApplication2. I then added docker support (Docker for Windows, Windows Containers). Compose file looks like this:
version: '3.4'
services:
webapplication1:
image: compositeapp
build:
context: .\WebApplication1
dockerfile: Dockerfile
webapplication2:
image: compositeapp
build:
context: .\WebApplication2
dockerfile: Dockerfile
So both containers are in a single image. Webapplication1 dockerfile has ENV LICENSE=abc123 and webapplication2 dockerfile has ENV LICENSE=abc456.
After building and starting the containers, I used exec -it powershell to remote into the 2 containers and did get-item env:license. Both containers returned 456.
As a newbie, I was expecting one machine to return abc123 and the other abc456. I just made up the environment name as being license, but what does one do if they need a per container environment variable?
I guess the issue you notice provides from the fact you specified the same image name for both services, which implies that they will have the same ENV variable as defined in the latest-compiled Dockerfile.
Could you try this instead?
version: '3.4'
services:
webapplication1:
image: compositeapp1
build:
context: .\WebApplication1
dockerfile: Dockerfile
webapplication2:
image: compositeapp2
build:
context: .\WebApplication2
dockerfile: Dockerfile
Anyway, even if this is working, I assume your two Dockerfile are almost the same (?), in which case I would rather suggest to use a single Dockerfile and a single image tag, but customize the environment of both services by using some environment section in your docker-compose.yml (or some env_file section, along with some external .env files...).
For example, you may want to write something like this:
version: '3.4'
services:
webapplication1:
image: compositeapp
build:
context: .\WebApplication
dockerfile: Dockerfile
environment:
- LICENSE=abc123
webapplication2:
image: compositeapp
environment:
- LICENSE=abc456
(not forgetting to remove the ENV LICENSE=... line from the Dockerfile)

DOCKER_REGISTRY value is not set build error

I'm doing some experimenting with .NET Core 2.1, React/Redux, and Docker. Without making any changes to the boilerplate ASP.NET Core with React code generated, I added Docker support to the project.
Now the project doesn't build!
When I attempt to build, I get the error
DOCKER_REGISTRY value is not set build error.
Attempting to fix this, I tried changing my docker-compose file to be like this:
version: '3.4'
services:
project:
image: ${DOCKER_REGISTRY}project
build:
context: .
dockerfile: Project\Dockerfile
environment:
DOCKER_REGISTRY = "docker.io"
But, this didn't work. I assume I'm missing something pretty straightforward.
Thanks in advance!
UPDATE:
I got a little bit further by thinking that I don't have an image saved in docker.io, so why should I be trying to pull one down? I changed my docker-compose file to look like this:
version: '3.4'
services:
project:
build:
context: .
dockerfile: project\Dockerfile
And now the project will at least build - but it won't debug, because I now get an error on the second step of 7:
Service 'project' failed to build: COPY failed: CreateFile \\?\C:\ProgramData\Docker\tmp\docker-builder965605424\src: The system cannot find the file specified..
This is an issue with Docker Compose version 1.21.2 https://github.com/docker/compose/issues/5969 so you could either switch to the stable channel or update your docker-compose.yml to look like the following one:
version: '3.4'
services:
project:
image: ${DOCKER_REGISTRY}project
build:
context: Project
dockerfile: ./Dockerfile
Try it like this (change your docker-compose to pass build args rather then setting environment variables).
version: '3.4'
services:
project:
image: ${DOCKER_REGISTRY}/project
build:
context: .
dockerfile: Project\Dockerfile
agrs:
- DOCKER_REGISTRY = "docker.io"

build contains unsupported option: 'ports'

Trying to use docker-compose for the first time, but not having much luck. I have the following setup:
docker-compose version 1.8.0, build f3628c7
/home/GabeThermComposer contains the docker-compose.yml
/home/GabeThermComposer/GabeThermApache contains Dockerfile
/home/GabeThermComposer/GabeThermPHPMyAdmin contains Dockerfile
/home/GabeThermComposer/GabeThermDB contains Dockerfile and nest-init.sql
When I create docker images using the Dockerfile in each subdir, it all works without issues. I was hoping with the docker-compose.yml to do all the seperate building of images at once.
The docker-compose.yml looks like this:
version: '2'
services:
GabeThermDB:
build:
context: ./GabeThermDB
dockerfile: Dockerfile
GabeThermApache:
build:
context: ./GabeThermApache
dockerfile: Dockerfile
ports:
- "80:80"
GabeThermPHPMyAdmin:
build:
context: ./GabeThermPHPMyAdmin
dockerfile: Dockerfile
ports:
- "8080:80"
When trying to run "docker-compose up", I get the following error:
ERROR: The Compose file './docker-compose.yml' is invalid because:
services.GabeThermPHPMyAdmin.build contains unsupported option: 'ports'
services.GabeThermApache.build contains unsupported option: 'ports'
I have no clue on what is wrong with this. I think I did exactly as other examples have shown. Btw, I do know that the "context:" and "dockerfile:" is overdone, but since I'm new, I wanted to be sure to what files I'm pointing in case I forget it automatically dives into the subdir and runs the Dockerfile.
Any help is appreciated.
You have to move the ports out of the build block.
version: '2'
services:
GabeThermDB:
build:
context: ./GabeThermDB
dockerfile: Dockerfile
GabeThermApache:
build:
context: ./GabeThermApache
dockerfile: Dockerfile
ports:
- "80:80"
GabeThermPHPMyAdmin:
build:
context: ./GabeThermPHPMyAdmin
dockerfile: Dockerfile
ports:
- "8080:80"

Resources