导出、恢复、上传镜像

[root@localhost ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED              VIRTUAL SIZE
centos-6-x86        latest              8fca9486a39b        About a minute ago   341.3 MB
centos_with_net     latest              3e8ea8607f08        2 weeks ago          294.9 MB
centos              latest              9baab0af79c4        4 weeks ago          196.7 MB

把现有镜像导出为一个文件

[root@localhost ~]# docker save -o centos_with_net.tar 3e8ea8607f08

3e8ea8607f08是镜像的ID,也可以换成镜像名字centos_with_net,导出的文件生成在当前目录下

[root@localhost ~]# ls
anaconda-ks.cfg              centos_with_net.tar  install.log.syslog  模板  图片  下载  桌面
centos-6-x86-minimal.tar.gz  install.log          公共的              视频  文档  音乐
[root@localhost ~]# du -sh centos_with_net.tar
289M    centos_with_net.tar

用导出文件恢复本地镜像

[root@localhost ~]# docker load < centos_with_net.tar

或者

[root@localhost ~]# docker load --input centos_with_net.tar

上传镜像

可以使用docker push命令上传镜像到仓库,默认上传到DockerHub官方仓库,命令格式为docker push NAME[:TAG]。

用户在DockerHub网站注册后,即可上传自制的镜像。

docker push image_name

第一次使用时,会提示输入登录信息或进行注册。

原文地址:https://www.cnblogs.com/Genesis2018/p/8304721.html