有什么方法可以将“修补程序”应用于泊坞窗图像?

有什么办法可以将“补丁”应用到docker镜像,特别是一个或多个RUNADD等命令?

例如, RUN命令可能需要20分钟才能运行,即下载,编译和安装二进制文件。 是否有可能采取差异,并将其应用到另一个图像?

我能想到的唯一方法就是运行docker diff ,parsing输出,创build一个tgz,然后在另一个Dockerfile使用tgz作为ADD

我知道有这个问题,例如,如果事先调用一个apt-get update ,这可能会打破二进制预期的dynamic库链接,等等。我可以这样做,因为我的testing将失败,并会显示我必须再次重build“差异”。

我也意识到可能会有冲突。 我很高兴完全replace文件。

这个function的原因是为了节省时间。 例如,有时候早期的Dockerfile命令需要改变,并且会破坏caching。 另外,尽量使它们相同以利用caching,但在两个不同的Docker文件中的前面的命令不可能总是相同。

简短的回答是,不,你不能这样做。

漫长的回答是,如果有足够的动机,你可以编写能够做你想做的事情的代码。 我在这里写了一些关于docker图像格式的文档(和一个用于处理这些图像的工具):

这可能会给你一些关于从哪里开始的想法。

就我个人而言,我怀疑这种努力是不值得的。

我看到我们可以使用不同的方法来应用补丁或更新。

 1.Patching using the Dockerfile 2.Patching an instance of the container and converting it to an image 

我遵循第二个程序来应用任何补丁。 这有助于在构build或推送回购之前testing和更新我的映像。

  1. Create a container from the image you would like to update. 2. Inside the container, run the native package manager and update the desired packages or patches. 3. Exit the container instance. 4. Commit the changes done to get the updated image. 5. Stop the containers that were instantiated from the pre-updated image. 6. Instantiate new containers from the update image.