复制Docker实例化文件时出错

时间:2017-05-23 20:47:51

标签: linux docker

我试图从Github上获取Docker应用程序。我已经更改了其中一个python文件,所以我不想让docker从Github中取出,我希望它从机器上的目录(Ubuntu)中取出。

原始Dockerfile:

RUN pip install --no-cache-dir requests==2.7.0
RUN pip install --no-cache-dir simplejson==3.7.3
RUN pip install --no-cache-dir six==1.10.0
RUN pip install --no-cache-dir twilio==4.4.0
RUN pip install --no-cache-dir twill==1.8.0
RUN pip install --no-cache-dir wsgiref==0.1.2
RUN pip install --no-cache-dir zope.interface==4.1.2
RUN pip install --no-cache-dir PyQRCode==1.2.1
RUN pip install --no-cache-dir pypng==0.0.18
RUN pip install --no-cache-dir htmlmin==0.1.10
RUN pip install --no-cache-dir sendgrid==3.6.5

RUN wget -O master.zip https://github.com/thinkst/canarytokens/archive/master.zip?step=1
RUN unzip master.zip
RUN mv /canarytokens-master/* /srv
RUN rm -rf /canarytokens-master
WORKDIR /srv

CMD echo "Please use the docker-compose setup described at https://github.com/thinkst/canarytokens-docker"

我编辑过的Dockerfile:

RUN pip install --no-cache-dir requests==2.7.0
RUN pip install --no-cache-dir simplejson==3.7.3
RUN pip install --no-cache-dir six==1.10.0
RUN pip install --no-cache-dir twilio==4.4.0
RUN pip install --no-cache-dir twill==1.8.0
RUN pip install --no-cache-dir wsgiref==0.1.2
RUN pip install --no-cache-dir zope.interface==4.1.2
RUN pip install --no-cache-dir PyQRCode==1.2.1
RUN pip install --no-cache-dir pypng==0.0.18
RUN pip install --no-cache-dir htmlmin==0.1.10
RUN pip install --no-cache-dir sendgrid==3.6.5

RUN cp /var/www/html/canarytokens-master.zip master.zip
RUN unzip master.zip
RUN mv /canarytokens-master/* /srv
RUN rm -rf /canarytokens-master
WORKDIR /srv

CMD echo "Please use the docker-compose setup described at https://github.com/thinkst/canarytokens-docker"

我所做的唯一改变是将行RUN wget -O master.zip https://github.com/thinkst/canarytokens/archive/master.zip?step=1更改为RUN cp /var/www/html/canarytokens-master.zip master.zip

原版运行正常,应用程序完全正常运行。编辑过的一个给我以下错误:

cp: cannot stat '/var/www/html/canarytokens-master.zip': No such file or directory

我已经尝试将canarytokens-master.zip文件放在不同的位置,包括" /"和" / opt" - 导致同样的问题。我已经更改了文件的权限,以便任何人都可以读/写/执行 - 同样的问题。而且我已经确认该文件肯定存在。我可以做一个" cp /var/www/html/canarytokens-master.zip master.zip"在命令行手动,它将正确复制文件。

有什么想法吗?

1 个答案:

答案 0 :(得分:0)

无论您使用RUN cp ....做什么都是构建映像的容器的本地,而且与主机文件系统无关。

您需要将该zip文件放在构建的 context 中(简单地说是放置Dockerfile的目录)。然后执行COPY ./thefile.zip /srv