Search code examples
docker

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


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?


Solution

  • The COPY instruction in the Dockerfile copies the files in src to the dest folder. Looks like you are either missing the file1, file2 and file3 or trying to build the Dockerfile from the wrong folder.

    Refer Dockerfile Doc

    Also the command for building the Dockerfile should be something like.

    cd into/the/folder/
    docker build -t sometagname .