docker 镜像保存

DescriptionSave one or more images to a tar archive (streamed to STDOUT by default)
Usagedocker image save [OPTIONS] IMAGE [IMAGE...]
Aliases
docker save

描述

生成一个压缩的仓库到标准输出流。 包含所有父层,以及所有标签和版本,或指定的repo:tag,针对每个提供的参数。

选项

OptionDefaultDescription
-o, --outputWrite to a file, instead of STDOUT

示例

创建一个备份,然后可以与docker load一起使用。

$ docker save busybox > busybox.tar

$ ls -sh busybox.tar

2.7M busybox.tar

$ docker save --output busybox.tar busybox

$ ls -sh busybox.tar

2.7M busybox.tar

$ docker save -o fedora-all.tar fedora

$ docker save -o fedora-latest.tar fedora:latest

使用gzip将图像保存为tar.gz文件

你可以使用gzip来保存图像文件并使备份更小。

$ docker save myimage:latest | gzip > myimage_latest.tar.gz

挑选特定标签

你甚至可以挑选镜像仓库中的特定标签。

$ docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy