首页 技术 正文
技术 2022年11月11日
0 收藏 486 点赞 4,414 浏览 1860 个字

在没有Docker Registry时,可以通过docker savedocker load命令完成镜像迁移的过程,先将镜像保存为压缩包,然后在其他位置再加载压缩包。

将镜像保存为压缩包文件

[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 ~]#
[root@TestNode ~]# ip addr show enp0s3
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:3c:d9:72 brd ff:ff:ff:ff:ff:ff
inet 10.140.1.120/24 brd 10.140.1.255 scope global dynamic enp0s3
valid_lft 84898sec preferred_lft 84898sec
inet6 fe80::a00:27ff:fe3c:d972/64 scope link
valid_lft forever preferred_lft forever
[root@TestNode ~]#
[root@TestNode ~]# docker images hello-world
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/hello-world latest 48b5124b2768 3 months ago 1.84 kB
[root@TestNode ~]#
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,945
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,471
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,284
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,100
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,732
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,767