DOCKER_REGISTRY value is not set build error - docker

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"

Related

How to pass the right context to docker-compose build?

I have the following docker-compose file:
version: "3.9"
services:
repo_svc:
build:
context: ../
dockerfile: ../build/Dockerfile
Running the command, I have got the following error message:
docker-compose -f ./deployments/docker-compose.yml build
Building repo_svc
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/developer/versioner/services/build: no such file or directory
ERROR: Service 'repo_svc' failed to build : Build failed
The folder structure of GO project:
I would like to pass to context: ../ the repo-svc folder context. However, I do not know why it is looking in the /home/developer/versioner/services/build folder. It even does not exist.
I think the context should look like:
version: "3.9"
services:
repo_svc:
build:
context: ../build
dockerfile: Dockerfile

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.

Docker. Symlink INSIDE context not working

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

Dockerfile pass environments on docker compose build

I have written a Dockerfile which uses two arguments:
FROM jessie
MAINTAINER Zeinab Abbasimazar
#Build Arguments
ARG REP_USER
ARG REP_PASS
# Build
RUN echo 'REP_USER:'$REP_USER', REP_PASS:'$REP_PASS
I wrote a docker-compose.yml for build:
version: "2"
services:
ui:
build:
context: .
dockerfile: Dockerfile
args:
REP_USER: $REP_USER
REP_PASS: $REP_PASS
I don't want to define these arguments directly in the compose file, so I tried to send them during docker compose build:
REP_USER=myusername REP_PASS=mypassword docker-compose build
Which didn't work. I changed my Dockerfile to use these arguments as environment variables; so I removed ARG lines:
FROM jessie
MAINTAINER Zeinab Abbasimazar
# Build
RUN echo 'REP_USER:'$REP_USER', REP_PASS:'$REP_PASS
And docker-compose.yml:
version: "2"
services:
ui:
build:
context: .
dockerfile: Dockerfile
And ran REP_USER=myusername REP_PASS=mypassword docker-compose build; still no result.
I also tried to save these information into an env file:
version: "2"
services:
ui:
build:
context: .
dockerfile: Dockerfile
env_file:
- myenv.env
But it seems env files doesn't affect at build time; they are just take part into run time.
EDIT 1:
Docker version is 1.12.6 which doesn't support passing arguments with --build-arg.
EDIT 2:
I tried using .env file as described here:
cat .env
REP_USER=myusername
REP_PASS=mypassword
I then called docker-compose config which returned:
networks: {}
services:
ui:
build:
args:
REP_PASS: mypassword
REP_USER: myusername
context: /home/zeinab/Workspace/ZiZi-Docker/Test/test-exec-1
dockerfile: Dockerfile
version: '2.0'
volumes: {}
Which means this resolved my issue.
EDIT 3:
I also tried third section of docker-compose arg documentation in my docker-compose.yml file:
version: "2"
services:
ui:
build:
context: .
dockerfile: Dockerfile
args:
- REP_USER
- REP_PASS
And executed:
export REP_USER=myusername;export REP_PASS=mypassword;sudo docker-compose build --no-cache
Still not getting what I wanted.
You can set build arguments with docker compose as described here:
docker-compose build [--build-arg key=val...]
docker-compose build --build-arg REP_USER=myusername --build-arg REP_PASS=mypassword
Btw, AFAIK build arguments are a compromise between usability and deterministic building. Docker aims to build in a deterministic fashion. That is, wherever you execute the build the produced image should be the same. Therefore, it appears logical that the client ignores the environment (variables) it is executed in.
The correct syntax for variable substitution in a docker-compose file is ${VARNAME}.
Try with this one:
version: "2"
services:
ui:
build:
context: .
dockerfile: Dockerfile
args:
REP_USER: ${REP_USER}
REP_PASS: ${REP_PASS}
I finally found the solution. I mentioned it in the question too. I first tried it with fail, then I found out that I had a typo naming .env file; it was .evn.
I tried using .env file as described here:
cat .env
REP_USER=myusername
REP_PASS=mypassword
I then called docker-compose config which returned:
networks: {}
services:
ui:
build:
args:
REP_PASS: mypassword
REP_USER: myusername
context: /home/zeinab/Workspace/ZiZi-Docker/Test/test-exec-1
dockerfile: Dockerfile
version: '2.0'
volumes: {}
Which means this resolved my issue. I should mention that this answer was really helpful.

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