我了解 export
(用于容器)和 save
(用于图像)之间的区别。但归根结底,保存或导出生成的压缩包应该用作图像。
那么为什么有 2 个命令可以从 tarball 生成图像?
最佳答案
docker save
确实会生成一个 tarball,but 包含所有父层和所有标签 + 版本。
docker export
也会产生一个 tarball,但没有任何层/历史。
当一个人想要"flatten" an image时经常使用它。 ,如 Flatten a Docker container or image 中的“Thomas Uhrig”所示:
docker export <CONTAINER ID> | docker import - some-image-name:latest
但是,一旦生成了这些 tarball,加载/导入就可以:
-
docker import
从 one 压缩包创建 one 图像,这甚至图像(只是您要作为图像导入的文件系统)
Create an empty filesystem image and import the contents of the tarball
-
docker load
从 tarred 存储库创建可能 多个 图像(因为docker save
可以将 多个 图像保存在 tarball 中)。
Loads a tarred repository from a file or the standard input stream
关于docker - Docker中的导入和加载有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36925261/