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

13,599

Solution 1

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

Solution 2

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

Share:
13,599
user9287271
Author by

user9287271

Updated on June 12, 2022

Comments

  • user9287271
    user9287271 almost 2 years

    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?