docker镜像的导入导出
导出镜像
docker save -o 保存的文件名 要导出的镜像名
例如:
[root@iZbp1bgrqpp01m715mha18Z images]# cd /data/images
[root@iZbp1bgrqpp01m715mha18Z images]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xingt-admin latest cb30a2f70cab 4 weeks ago 486 MB
docker.io/nginx latest 6084105296a9 4 weeks ago 133 MB
docker.io/openjdk 15 051805fe9464 4 weeks ago 486 MB
docker.io/php 5.6-fpm 3458979c7744 2 years ago 344 MB
[root@iZbp1bgrqpp01m715mha18Z images]# docker save -o php:5.6-fpm.tar docker.io/php
[root@iZbp1bgrqpp01m715mha18Z images]# ll
total 343548
-rw------- 1 root root 351793152 Apr 12 10:17 php:5.6-fpm.tar
[root@iZbp1bgrqpp01m715mha18Z images]#
导入镜像
docker load --input 文件
或者
docker load < 文件名
例如:
[root@iZbp1bgrqpp01m715mha18Z ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xingt-admin latest cb30a2f70cab 4 weeks ago 486 MB
docker.io/nginx latest 6084105296a9 4 weeks ago 133 MB
docker.io/openjdk 15 051805fe9464 4 weeks ago 486 MB
[root@iZbp1bgrqpp01m715mha18Z ~]# cd /data/images
[root@iZbp1bgrqpp01m715mha18Z images]# ll
total 343548
-rw------- 1 root root 351793152 Apr 12 10:17 php:5.6-fpm.tar
[root@iZbp1bgrqpp01m715mha18Z images]# docker load --input php:5.6-fpm.tar
3c816b4ead84: Loading layer [==================================================>] 58.47 MB/58.47 MB
b87a266e6a9c: Loading layer [==================================================>] 3.584 kB/3.584 kB
82bded2c3a7c: Loading layer [==================================================>] 213.6 MB/213.6 MB
6eb3cfd4ad9e: Loading layer [==================================================>] 3.584 kB/3.584 kB
6e4f2e72b0d9: Loading layer [==================================================>] 13.74 MB/13.74 MB
5e2afcdec12b: Loading layer [==================================================>] 4.096 kB/4.096 kB
c9e57440aae2: Loading layer [==================================================>] 65.91 MB/65.91 MB
b6d5993da6a4: Loading layer [==================================================>] 11.78 kB/11.78 kB
56d6009fbc8b: Loading layer [==================================================>] 2.56 kB/2.56 kB
bf97b47da88d: Loading layer [==================================================>] 29.7 kB/29.7 kB
Loaded image: docker.io/php:5.6-fpm
[root@iZbp1bgrqpp01m715mha18Z images]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
xingt-admin latest cb30a2f70cab 4 weeks ago 486 MB
docker.io/nginx latest 6084105296a9 4 weeks ago 133 MB
docker.io/openjdk 15 051805fe9464 4 weeks ago 486 MB
docker.io/php 5.6-fpm 3458979c7744 2 years ago 344 MB
[root@iZbp1bgrqpp01m715mha18Z images]#