新的Docker --squash如何工作 [英] How does the new Docker --squash work

查看:1547
本文介绍了新的Docker --squash如何工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Docker 1.13 中,添加了新的-squash 参数.

In Docker 1.13 the new --squash parameter was added.

我现在希望减小图像的尺寸,并能够隐藏"图像.我的图层中有秘密文件.

I'm now hoping to reduce the size of my images as well as being able to "hide" secret files I have in my layers.

在下面,您现在可以看到与使用--squash参数进行构建时的区别.

Below you can now see the difference from doing a build with and without the --squash parameter.

无南瓜

带壁球

现在是我的问题.

如果我在第一层中添加了一个秘密文件,然后在第二层中使用了该秘密文件,最后在中删除了我的秘密文件.第三层,然后使用--squash标志进行构建.

If I add a secret file in my first layer, then use the secret file in my second layer, and the finally remove my secret file in the third layer, and then build with the --squash flag.

现在是否有任何方式来获取机密文件?

Will there be any way now to get the secret file?

推荐答案

如果我在第一层中添加了一个秘密文件,请在以下位置使用该秘密文件 我的第二层,最后在第三层中删除我的秘密文件 层,然后使用--squash标志进行构建.

If I add a secret file in my first layer, then use the secret file in my second layer, and the finally remove my secret file in the third layer, and then build with the --squash flag.

现在有什么方法可以获取机密文件吗?

Will there be any way now to get the secret file?

答案:您的图片没有秘密文件.

Answer: Your image won't have the secret file.

--squash的工作方式:

构建完成后,Docker将创建一个新图像,将来自每个层的差异加载到单个新层中,并引用父层的所有层.

Once the build is complete, Docker creates a new image loading the diffs from each layer into a single new layer and references all the parent's layers.

换句话说:当进行压缩时,Docker将采用构建生成的所有文件系统层,并将它们折叠到一个新的层中.

In other words: when squashing, Docker will take all the filesystem layers produced by a build and collapse them into a single new layer.

这可以简化创建最少容器图像的过程,但是在移动图像时可能会导致更高的开销(因为无法再在图像之间共享被压缩的图层). Docker仍然缓存各个层,以加快后续构建的速度.

This can simplify the process of creating minimal container images, but may result in slightly higher overhead when images are moved around (because squashed layers can no longer be shared between images). Docker still caches individual layers to make subsequent builds fast.

请注意,此功能会将所有新建的图层压缩为一个图层,而不是从头开始压缩.

Please note this feature squashes all the newly built layers into a single layer, it is not squashing to scratch.

旁注:

Docker 1.13还支持使用--compress标志压缩从CLI发送到守护程序的构建上下文.这样可以减少发送的数据量,从而加快在远程守护程序上完成的构建.

Docker 1.13 also has support for compressing the build context that is sent from CLI to daemon using the --compress flag. This will speed up builds done on remote daemons by reducing the amount of data sent.

请注意,从Docker 1.13开始,此功能是实验性的.

Please note as of Docker 1.13 this feature is experimental.

这篇关于新的Docker --squash如何工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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