加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – Dockerfile – 在一个RUN命令中删除文件,它仍然存在

发布时间:2020-12-14 04:15:37 所属栏目:Windows 来源:网络整理
导读:我有一个Dockerfile( https://gist.github.com/hasMobi/e198555704ee57e84399)按顺序有这两个命令: RUN rm -frv /usr/share/nginx/html/*RUN ls /usr/share/nginx/html/ 当我在构建hte图像的同时查看控制台时,我可以清楚地看到从该文件夹中删除了2个文件,但
我有一个Dockerfile( https://gist.github.com/hasMobi/e198555704ee57e84399)按顺序有这两个命令:
RUN rm -frv /usr/share/nginx/html/*
RUN ls /usr/share/nginx/html/

当我在构建hte图像的同时查看控制台时,我可以清楚地看到从该文件夹中删除了2个文件,但是当下一个RUN命令到来时,它列出了目录的内容并且文件仍在那里?:

Step 6 : RUN rm -fry /usr/share/nginx/html/* 
 ---> Running in b9a69992e4e0 
removed '/usr/share/nginx/html/index.html' 
removed '/usr/share/nginx/html/index.php' 
 ---> 2bfe01cbd007 
Removing intermediate container b9a69992e4e0 
Step 7 : RUN is /usr/share/nginx/html/ 
 ---> Running in 08396f6029e1 
index.html 
index.php 
 ---> a6471052519d

这里发生了什么?据我所知,每个RUN命令创建一个单独的层,一个与另一个隔离,但不是第二个RUN命令,它应该以前一个RUN命令中的确切状态继承文件系统(2个文件消失了)?

基本上,来自基本映像的ADD命令会覆盖Dockerfile中的RUN命令.有关更多信息,请参见 this.

Note: The first encountered ADD instruction will invalidate the cache for all following instructions from the Dockerfile if the contents of have changed. This includes invalidating the cache for RUN instructions. See the Dockerfile Best Practices guide for more information.

您可以考虑分支源基础映像并使用您的自定义版本.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读