Docker save/load 与 export/import
2019-03-05 本文已影响0人
心水Diana
export/import
Description
Export a container’s filesystem as a tar archive
将容器导出为tar文件.
命令
- export
docker export <container id/name> > latest.tar
docker export --output=" latest.tar" <container id/name>
![](https://img.haomeiwen.com/i12142434/773a9a30592550d4.png)
- import
Description
Import the contents from a tarball to create a filesystem image
将export导出tar包导入
# 从文件 URL 中导入
docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
cat exampleimage.tgz | docker import - exampleimagelocal:new
![](https://img.haomeiwen.com/i12142434/f926948c30004ef6.png)
- save
Description
Save one or more images to a tar archive (streamed to STDOUT by default)
将镜像保存至tar文件中
docker save busybox > busybox.tar
docker save -o fedora-all.tar fedora
![](https://img.haomeiwen.com/i12142434/64cc0014fd04086d.png)
- load
Description
Load an image from a tar archive or STDIN
从文件或者标准输入 载入 镜像
docker load < alpine.tar.gz
![](https://img.haomeiwen.com/i12142434/664fa1f16a4b3dd3.png)
- commit
Description
Create a new image from a container’s changes
容器最上层为R/W 保存修改后容器
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
docker commit alpine apline:v1
commit 提交容器为黑箱操作。建议使用Dockerfile,操作步骤明确可查。