Docker image migration
Experimental environment
Operating system: CentOS Linux release 7.3.1611 (Core) docker version: 17.11.0-ce
image copies
To view an existing docker image:
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
eg_postgresql latest 431a93e7033e 2 weeks ago 318MB
centos latest 3fa822599e10 4 weeks ago 204MB
hello-world latest f2a91732366c 5 weeks ago 1.85kB
Save the image Hello world as an archive file and compress to generate the compression package Hello world lastest.tar.gz
[root@localhost ~]# docker save hello-world |gzip >hello-world-lastest.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg Documents hello-world-lastest.tar.gz Music Pictures Templates
Desktop Downloads initial-setup-ks.cfg original-ks.cfg Public Videos
Load image
I use a machine here, so delete the Hello world image first, and then use the load command to restore:
To delete a mirror:
[root@localhost ~]# docker rmi f2a91732366c --force
Untagged: hello-world:latest
Untagged: hello-world@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
Deleted: sha256:f2a91732366c0332ccd7afd2a5c4ff2b9af81f549370f7a19acd460f87686bc7
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
eg_postgresql latest 431a93e7033e 2 weeks ago 318MB
centos latest 3fa822599e10 4 weeks ago 204MB
Load the mirrored archive package:
[root@localhost ~]# docker load -i hello-world-lastest.tar.gz
Loaded image: hello-world:latest
Check the image in the machine:
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
eg_postgresql latest 431a93e7033e 2 weeks ago 318MB
centos latest 3fa822599e10 4 weeks ago 204MB
hello-world latest f2a91732366c 5 weeks ago 1.85kB
Found that the Hello world image has been successfully recovered