I have a Dockerfile set up in my root (~) folder. The first three lines of my file look like this:
COPY file1 /root/folder/
COPY file2 /root/folder/
COPY file3 /root/folder/
but it returns the following error for each line:
No such file or directory
The files are in the same directory as my Dockerfile and I am running the command docker build - < Dockerfile
in the same directory in terminal as well.
What am I doing wrong here exactly?
Do check the
.dockerignore
file too.I know this is a very rare case, but I had that file mentioned there.
File not found error with Docker put_archive. I am using the Python API for docker. Docker version 1.12.5, build 7392c3b
I am unable to copy files to a created docker container.
If I change the order of operation there is no error and the files are copied exactly to were I want them. So I know my code is working and doing what I want it to do. But its important to copy configuration files to a container before it is started. Coping the files after the start cuases the container to start with a default configuration and not the custom configuration which needs to be copied into place before the container is started. Docker claims that this issue is closed but it is still affecting my application.
This works; Same code different execution order.
The COPY instruction in the
Dockerfile
copies the files insrc
to thedest
folder. Looks like you are either missing thefile1
,file2
andfile3
or trying to build theDockerfile
from the wrong folder.Refer Dockerfile Doc
Also the command for building the
Dockerfile
should be something like.one of the way to don't use stdin and keep the context is:
1) in your Dockerfile, you should add
2) after, you should go on the parent of /your_dir_to_copy dir
2) then run this command
3) after you create your container
4) After you will get your directory copied in your container
I feel a little stupid, but my issue was that I was running docker-compose, and my Dockerfile was in a ./deploy subdirectory. My ADD reference needed to be relative to the root of the project, not the Dockerfile.
Changed: ADD ./file.tar.gz /etc/folder/ to: ADD ./deploy/file.tar.gz /etc/folder/
Anyhow, thought I'd post in case someone ran into the same issue.
It is possibly caused by you are referring file1/file2/file3 as an absolute path which is not in build context, Docker only search the path in build context.
E.g. if you use COPY /home/yourname/file1, Docker build interprets it as ${docker build working directory}/home/yourname/file1, if no file with same name here, no file or directory error is thrown.
Refer to One of the docker issue