为Docker实例化复制文件时出错

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

原始docker文件:

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”,它会复制文件。

有任何想法吗?

不pipe你用RUN cp ....做什么都是build立映像的容器的本地,而且不需要你的主机文件系统。

您需要将该zip文件放置在构build的上下文中(最后是放置Dockerfile的目录)。 然后执行COPY ./thefile.zip /srv