Docker镜像迁移-保存为文件及从文件导入镜像的方法

         有时候我们需要将docker镜像复制到内网的少数服务器上,搭建私有仓库显然没有这个必要,此时可以在已有的镜像服务器上将镜像保存为文件上传到其他服务器再从文件中载入镜像。

1、导出到文件

[root@localhost docker]# docker images
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
192.168.14.121:5000/centos   latest              589dc4d40385        8 hours ago         237MB
centos                       latest              589dc4d40385        8 hours ago         237MB
registry                     latest              f32a97de94e1        10 months ago       25.8MB
[root@localhost docker]# docker save -o centos_image.docker centos

2、从文件载入镜像

[root@localhost docker]# docker rmi 589dc4d40385
Untagged: centos:latest
Untagged: centos@sha256:05c09d2d9769643a5b6a777ec7cb3f5343f3d5ebb83d0c3eff0fbeca7e693bd4
Deleted: sha256:589dc4d40385ebd01340594e66c2ead3b193460efd6270f0e2dffd6db0e2f1c4
Deleted: sha256:0683de2821778aa9546bf3d3e6944df779daba1582631b7ea3517bb36f9e4007
[root@localhost docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
registry            latest              f32a97de94e1        10 months ago       25.8MB
[root@localhost docker]# docker load -i centos_image.docker
0683de282177: Loading layer [==================================================>]  244.9MB/244.9MB
Loaded image: centos:latest
[root@localhost docker]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              589dc4d40385        8 hours ago         237MB
registry            latest              f32a97de94e1        10 months ago       25.8MB
[root@localhost docker]# 
发布了22 篇原创文章 · 获赞 7 · 访问量 511

猜你喜欢

转载自blog.csdn.net/bjywxc/article/details/103992434
今日推荐