8

I got an error:

COPY failed: stat /var/lib/docker/tmp/docker-builder700869788/private: no such file or directory .

I wrote in Dockerfile:

FROM "centos"

    RUN mkdir ~/.ssh
    COPY ./private ~/.ssh/id_rsa
    RUN yum install -y https://centos7.iuscommunity.org/ius-release.rpm
    RUN yum install -y wget
    RUN yum update -y

and when I run docker build ./ -t docker/app,I got an error:

Status: Downloaded newer image for centos:latest
 ---> ff426288ea90
Step 2/22 : RUN mkdir ~/.ssh
 ---> Running in 49d3950mwpion
Removing intermediate container 49d73360f899
 ---> 24shentufhckm
Step 3/22 : COPY ./private ~/.ssh/id_rsa
COPY failed: stat /var/lib/docker/tmp/docker-builder700869788/private: no such file or directory  .

Of course, private key is in my PC.Now this Dockerfile is in myname/Desktop/app/Dockerfile .And private ket is in ~/.ssh/id_rsa .Is this error meaning directory wrong?

Kenster
  • 23,465
  • 21
  • 80
  • 106
user9287271
  • 291
  • 2
  • 7
  • 17
  • 1
    Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Feb 06 '18 at 05:31
  • 1
    Did you include the "private" directory in your build context (the directory at the end of your build command)? Do you have a .dockerignore file, and if so, what's in there? – BMitch Feb 06 '18 at 15:05

2 Answers2

4

You should put the file into the same directory with Dockerfile.

ABCD
  • 7,914
  • 9
  • 54
  • 90
1

Did you try to run docker build from outside the Dockerfile directory? It worked for me: docker build dir/.