docker迁移镜像

docker迁移镜像

手动

将镜像保存为压缩包文件

[root@CentOS-7 ~]# docker images nginx
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/nginx     latest              5766334bdaa0        2 weeks ago         182.5 MB
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# docker save  nginx | gzip > nginx-latest.tar.gz
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# ls -lh nginx-latest.tar.gz 
-rw-r--r-- 1 root root 69M Apr 24 17:28 nginx-latest.tar.gz
[root@CentOS-7 ~]#

加载镜像

# docker images nginx
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
# 
# docker load -i nginx-latest.tar.gz 
5d6cbe0dbcf9: Loading layer [==================================================>] 129.2 MB/129.2 MB
aca7b1f22e02: Loading layer [==================================================>] 9.216 kB/9.216 kB
31fc28b38091: Loading layer [==================================================>] 61.24 MB/61.24 MB
97b903fe0f6f: Loading layer [==================================================>] 3.584 kB/3.584 kB
Loaded image: docker.io/nginx:latest>                                           ]    512 B/3.584 kB
# 
# docker images nginx
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
docker.io/nginx     latest              5766334bdaa0        2 weeks ago         182.5 MB
# 

快捷命令

将镜像从一个主机迁移到另一个主机:

docker save | bzip2 | ssh @ "cat | docker load"
[root@CentOS-7 ~]# docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
docker.io/hello-world   latest              48b5124b2768        3 months ago        1.84 kB
[root@CentOS-7 ~]# 
[root@CentOS-7 ~]# docker save hello-world | bzip2 | ssh root@10.140.1.120 "cat | docker load"
root@10.140.1.120's password: 
Loaded image: docker.io/hello-world:latest
[root@CentOS-7 ~]# 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值