只需要在Docker文件中进行其他更改即可重建相同的Docker映像 [英] Rebuild same docker image with only the additional changes in the Dockerfile

查看:307
本文介绍了只需要在Docker文件中进行其他更改即可重建相同的Docker映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Dockerfile构建了一个Docker镜像。构建映像后,我对Dockerfile进行了一些基本的更改。只需进行其他更改就可以重建相同的图像。既然,创建图像需要很长时间,我不想完全构建它。感谢提前。

解决方案

所有Docker都按照你所描述的方式构建工作。



唯一需要考虑的是层次依赖。



考虑Dockerfile

  FROM something 
RUN cmd1
RUN cmd2
RUN cmd3
RUN cmd4

如果您更改 cmd1 ,则所有图层都将重建,因为它们可能与 cmd1

如果您更改 cmd4 ,只能重建此命令,因为它不影响任何其他



想想什么命令需要以什么顺序运行 - 也许你可以通过重新排列语句来改善它。


I build an docker image using a Dockerfile. After building the image, I made some basic changes on the Dockerfile. Is it possible to rebuild the same image with just the additional changes. Since, it takes very long time to create the image, I don't want to build it completely. Thanks in advance.

解决方案

All docker build work in the way, that you describe.

The only thing need to be taken into account is layer dependencies.

Consider Dockerfile

FROM something
RUN  cmd1
RUN  cmd2
RUN  cmd3
RUN  cmd4

If you change cmd1 then all layers will be rebuilt, because they could be different with respect to cmd1
If you change cmd4 than only this command will be rebuilt, because it has not affect any other layers.

Think about what commands need to be run in what order - maybe you can improve it by reordering the statements.

这篇关于只需要在Docker文件中进行其他更改即可重建相同的Docker映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆