如何平铺Docker图像? [英] How to flatten a Docker image?
问题描述
保存
图像!)到一个tarball并重新导入它,该图像只有3GB大。当然,这个历史已经失败了,但是对我来说这是可以的,因为我的意见中的形象是完成的,并准备好部署。 如果将图像/容器导出到磁盘并重新导入,该怎么平铺?而且:这是一个明智的做法,或者我缺少一些重要的一点?
,你不能使用Docker api。 docker export
和 docker import
是为这种情况设计的,正如你自己已经提到的那样。
如果您不想保存到磁盘,则可能将导出的输出流管道输入到输入流中。我没有测试过,但尝试
docker export red_panda | docker import - exampleimagelocal:new
I made a Docker container which is fairly large. When I commit the container to create an image, the image is about 7.8 GB big. But when I export
the container (not save
the image!) to a tarball and re-import it, the image is only 3 GB big. Of course the history is lost, but this OK for me, since the image is "done" in my opinion and ready for deployment.
How can I flatten an image/container without exporting it to the disk and importing it again? And: Is it a wise idea to do that or am I missing some important point?
To my knowledge, you cannot using the Docker api. docker export
and docker import
are designed for this scenario, as you yourself already mention.
If you don't want to save to disk, you could probably pipe the outputstream of export into the input stream of import. I have not tested this, but try
docker export red_panda | docker import - exampleimagelocal:new
这篇关于如何平铺Docker图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!