[英]Disadvantages of docker --squash
I wanted to know about the disadvantages of docker --squash
in a production environment.我想知道
docker --squash
在生产环境中的缺点。 The reason why I am using this command is: I needed dependencies(gcc,make,autoconf, etc) to build my PHP-react project.我使用此命令的原因是:我需要依赖项(gcc、make、autoconf 等)来构建我的 PHP-react 项目。 Also, I have created my own PHP base image which gives me these packages.
此外,我还创建了自己的 PHP 基本映像,它为我提供了这些包。 Now, the problem is I want to uninstall these dependencies once my project is built.
现在,问题是我想在构建项目后卸载这些依赖项。 I tried adding a
RUN apt-get remove gcc make
command at the end of Dockerfile but as this will be a separate layer from where these dependencies were installed, the overall size of the docker image remains the same.我尝试在 Dockerfile 的末尾添加一个
RUN apt-get remove gcc make
命令,但由于这将是安装这些依赖项的单独层,因此 docker 图像的整体大小保持不变。 I found about the docker --squash which will merge all layers into 1 layer and I have achieved ~33% space reduction.我发现 docker --squash 会将所有层合并为一层,我已经实现了约 33% 的空间减少。 But the problem is I can't use the docker squash command with docker-compose and also I don't understand if there are any performance issues or other disadvantages of using
docker --squash
in production.但问题是我不能将 docker squash 命令与 docker-compose 一起使用,而且我不明白在生产中使用
docker --squash
是否存在任何性能问题或其他缺点。
I got to know about multi stage build but this is not same as I don't know which files I should not be copying in order to remove those dependencies.我开始了解多阶段构建,但这与我不知道不应该复制哪些文件以删除这些依赖项不同。 And also there will be lot of directories to be copied if I use multi-stage build
如果我使用多阶段构建,也会有很多目录要复制
Thanks!谢谢!
I think they've provided the pros and the cons in its own document clearly.我认为他们已经在自己的文档中清楚地提供了优缺点。
Pro:亲:
Con:缺点:
The --squash
option is an experimental feature, and should not be considered stable. --squash
选项是一项实验性功能,不应被认为是稳定的。
Squashing images may actually have a negative impact on performance;压缩图像实际上可能会对性能产生负面影响; when pulling an image consisting of multiple layers, layers can be pulled in parallel, and allows sharing layers between images (saving space).
拉取包含多个图层的图像时,可以并行拉取图层,并允许图像之间共享图层(节省空间)。
Alternatively或者
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.