COPYing a file in a Dockerfile, no such file or di

2019-04-03 07:37发布

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?

标签: docker
13条回答
再贱就再见
2楼-- · 2019-04-03 08:25

I just experienced this problem and none of the suggestions here solved my problem. Turns out I had the wrong line endings in my file, and had to change them to the appropriate line endings. (In this case from CRLF to LF, so Ubuntu 14.04 would recognize the script, which I had been editing on windows.)

I changed the line endings using VSCode, and most code editors should have the option of choosing line endings.

Hope this helps someone.

查看更多
登录 后发表回答