COPY失败:stat / var / lib / docker / tmp / docker-builder700869788 / private:没有这样的文件或目录

时间:2018-02-06 02:00:00

标签: linux docker ssh

我收到了一个错误:

  

COPY失败:stat / var / lib / docker / tmp / docker-builder700869788 / private:没有这样的文件或目录。

我在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

当我运行docker build ./ -t docker/app时,出现错误:

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  .

当然,私钥在我的PC中。现在这个Dockerfile在myname / Desktop / app / Dockerfile中。并且私钥在〜/ .ssh / id_rsa。这个错误意味着目录错了吗?

2 个答案:

答案 0 :(得分:2)

您应该将文件与Dockerfile放在同一目录中。

答案 1 :(得分:1)

您是否尝试从Dockerfile目录外部运行docker build?它对我有用:docker build dir/