如何平铺Docker图像? [英] How to flatten a Docker image?

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

问题描述

我做了一个相当大的Docker容器。当我提交容器来创建图像时,图像大约为7.8 GB。但是当我将导出容器(而不是保存图像!)到一个tarball并重新导入它,该图像只有3GB大。当然,这个历史已经失败了,但是对我来说这是可以的,因为我的意见中的形象是完成的,并准备好部署。



如果将图像/容器导出到磁盘并重新导入,该怎么平铺?而且:这是一个明智的做法,或者我缺少一些重要的一点?

解决方案

,你不能使用Docker api。 docker export docker import 是为这种情况设计的,正如你自己已经提到的那样。



如果您不想保存到磁盘,则可能将导出的输出流管道输入到输入流中。我没有测试过,但尝试

  docker export red_pa​​nda | 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屋!

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