Reputation: 4292
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?
Upvotes: 6
Views: 12031
Reputation: 4738
One of the possibility is incorrect path in source
ADD ./directory/basic.conf /dir/
instead of
ADD basic.conf /dir/
Upvotes: 0
Reputation: 2320
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
Upvotes: 3
Reputation: 129
Hells bells all - for further clarification, because I needed it and it took me a bit to figure this out on my own:
With an ADD in the Dockerfile, you need to be in the directory relative to wherever you're adding - not relative to the Dockerfile.
ADD directory1\directory2\filename.jar app.jar
And your file structure is:
home
|-directory1
|-directory2
You need to be in home when you use:
docker build . -f filepathToDocker/Dockerfile
I imagine this might be true for COPY as well, but I haven't tested it.
Upvotes: 1
Reputation: 339
I also got the same error when I run docker in Ubuntu machine. I could resolve it by mentioning ${pwd} before the source file in ADD instruction.
Here, I had to copy 'apps' from /home/arun/ks/ to / in container.
So, I made a change in Dockerfile as below.
ADD ${PWD}/apps /apps
Then I built the docker image from the location of source file instead of location of Dockerfile.
$ pwd
/home/arun/ks/
$ ls apps web
$ sudo docker image build -t image-name . -f path-to-the-dockerfile
Here, we should use both . and -f option.
Upvotes: 0
Reputation: 1801
The most common causes of this issue are:
Incorrect path
Having docker-builder in your .dockerignore
Upvotes: 4
Reputation: 4292
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
Upvotes: 5