COPYing a file in a Dockerfile, no such file or directory?

101

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?

This question is tagged with docker

~ Asked on 2015-10-07 16:09:13

The Best Answer is


266

Do check the .dockerignore file too.

I know this is a very rare case, but I had that file mentioned there.

~ Answered on 2016-03-16 06:59:44


37

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

~ Answered on 2016-07-15 03:15:18


Most Viewed Questions: