如何在Docker中拍摄容器快照 [英] How to take container snapshots in docker

查看:1111
本文介绍了如何在Docker中拍摄容器快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何获取容器快照并将快照加载到另一个Docker主机中.我想知道容器快照,而不是图像快照.我对docker中的export/import和save/load命令感到困惑.我希望获得更多的清晰度或文档以更深入地了解它们.

How do we take container snapshots and load the snapshot in another docker host . I like to know the container snapshoting and not for image. I get confused with export/import and save/load commands in docker. I like to get more clarity or doc to understand them more deeply .

具有用于运行容器和屋顶的元数据的快照.其他Docker主机中存在的确切状态.朝这个方向提供帮助将非常有用.

The snapshot to have the metadata to run the container and the roofs . The exact state to be there in the other docker host. Help in this direction would be great.

推荐答案

命令docker commit 为您的容器拍摄快照.该快照是一个映像,您可以将其放在(专用)存储库中以将其拉到另一台主机上.

The command docker commit takes a snapshot of your container. That snapshot is an image, which you can put on a (private) repository to be able to pull it on another host.

不使用图像的选项(您说要避免)确实是加载.根据文档,这会将您的容器与所有文件层一起保存.因此,如果您使用子容器(例如 Ubuntu > JavaJDK > Elasticsearch > my-container )进行设置, 4个文件层将进入那里.但是您可能已经在其他主机上将前3层作为图像显示了,在这种情况下save会带来很多开销.然后,您可以使用导出

An option that does not use an image (which you say you want to avoid) is indeed save and load. According to the documentation this saves your container with all file layers. So if you have a setup with child containers such as Ubuntu > JavaJDK > Elasticsearch > my-container, all 4 file layers would get in there. But you may have the first 3 layers already present as images on the other host, in which case save amounts to a lot of overhead. Then, you can use export and import, which according to the documentation only exports the top file layer (in other words, the container, and not the images below it).

有关图像,容器,文件层等的更多信息,可以在官方文档(例如文件系统.

More information on the images, container, file layers etc can be found in the official documentation (e.g. file system.

这篇关于如何在Docker中拍摄容器快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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