镜像导入导出
在缺乏网络的环境中,可以将Docker镜像导出,进行离线部署。
一、save && load
docker save命令可以将多个镜像导出到文件中,用法如下:
>docker save --help
Usage: docker save [OPTIONS] IMAGE [IMAGE...]
Save one or more images to a tar archive (streamed to STDOUT by default)
Options:
--help Print usage
-o, --output string Write to a file, instead of STDOUT例如:
docker save -o wq_ci.tar postgres:10 jenkins/jenkins:lts sonarqube:lts在导出完成后,可以使用docker load -i <saved_image.tar>来加载导出的image。
二、export && import
docker export可以将container导出,用法如下:
例如:
使用docker import可以从导出文件生成image,例如:
三、save和export区别
docker save保存的是image,docker export保存的是container;docker load用来载入image,docker import用来载入container包,但两者都会恢复为image;docker load不能对载入的image重命名,而docker import可以为image指定新名称。
Last updated
Was this helpful?