When I try to build the following (simple) NGINX docker container https://github.com/MarvAmBass/docker-nginx-ssl-secure, it always fails with the following error: stat /var/lib/docker/tmp/docker-builder00Whatever/basic.conf: no such file or directory
My directory looks like this:
├── basic.conf
├── Dockerfile
├── entrypoint.sh
├── LICENSE
├── README.md
└── ssl.conf
Running the command sudo docker build - < Dockerfile
as root user doesn't change a thing.
Does anyone have a solution here?
The ADD command is used to copy files/directories into a Docker image. It can copy data in three ways: Copy files from the local storage to a destination in the Docker image. Copy a tarball from the local storage and extract it automatically inside a destination in the Docker image.
If the WORKDIR command is not written in the Dockerfile, it will automatically be created by the Docker compiler. Hence, it can be said that the command performs mkdir and cd implicitly. If the project directory does not exist, it will be created.
According to the documentation: The WORKDIR instruction sets the working directory for any RUN, CMD, ENTRYPOINT, COPY and ADD instructions that follow it in the Dockerfile. If the WORKDIR doesn't exist, it will be created even if it's not used in any subsequent Dockerfile instruction.
Ok, for me it worked to use docker build . -f Dockerfile
instead of docker build - < Dockerfile
(which was the suggestion from the offical docker documentation by the way: https://docs.docker.com/engine/reference/commandline/build/#tarball-contexts). The solution was taken from github: https://github.com/moby/moby/issues/34986#issuecomment-343680872
The most common causes of this issue are:
Incorrect path
Having docker-builder in your .dockerignore
I found the same error message when I used docker-compose.yml with follows directory structure. I fixed it by updating the dockerfile path in the docker-compose.yml as follows.
.docker
├── basic.conf
├── Dockerfile
My docker-compose.yml look like this when I found the error
services:
web:
build:
context: ./
dockerfile: .docker/nginx
I have solved the problem by update the docker-compose.yml as follows.
services:
web:
build:
context: ./
dockerfile: .docker/nginx/Dockerfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With