Preface
Everyone uses Docker to download images from the container repository, but this process may depend on the bandwidth of the network, so if you migrate a downloaded image to another environment, or how to implement a backup or restore of a docker container, or migrate, let's talk about it a bit.
--------------------------------------------------------------------------------------
Blog:http://blog.csdn.net/chinagissoft
QQ Group: 16403743
Tenet: Focus on "gis+" Frontier technology research and exchange, cloud computing technology, big Data technology, container technology, Internet of Things and GIS deep integration, explore "gis+" technology and industry solutions
Reprint Description: The article is allowed to reprint, but must be linked to the source address, otherwise investigate legal responsibility!
--------------------------------------------------------------------------------------
As we all know, Docker's filesystem is aufs, so our image is likely to be a new one on the basis of n images, so it is impossible to get the physical file of the Docker image to migrate, but Docker also gives you the relevant commands to implement the backup operation.
Goal
Migrating google/cadvisor mirrors from the source container environment 192.168.14.1 to 192.168.13.120 inside
1. View the image list of the 192.168.14.1 environment
root@controller:~# Docker images REPOSITORY TAG IMAGE ID CREATED SIZE UBUNTU_DESKTOP_V1 latest 3b97d2c886e0 4 days ago 971.3 MB Ubuntu_de Sktop latest 8421b0d33543 7 days ago 946.8 MB Spark-master Latest 4CF819691DCA 7 days ago 266.3 MB spark-base-2 Latest df1c40938e7f 9 days ago 266.3 MB spark-base-1 latest c091a4c160b7 9 days ago 266.3 MB spark-base-0 latest 6C41BD72FCCD 9 days ago 266.3 MB Spark-base latest 54c3c018a5e0 9 days ago 261.1 MB u Buntu base-spark A2101fbeeaac One days ago 261.1 MB Deploy_mysql Latest 8F70BD4222B1 2 weeks ago 324.7 MB deploy_ui latest 3d35eaace 8BF 2 weeks ago 765.3 MB Deploy_log latest 7F9DB19786B2 2 weeks Ago 188 mb 192.168.14.1:5008/ubuntu-local2 14.04 b72889fa879c 2 weeks ago 188 MB Lo Calhost:5008/ubuntu-local 14.04 b72889fa879c 2 weeks ago 188 MB Ubuntu 14.04 b72889fa879c 2 weeks ago 188 MB Ubuntu Latest b72889fa879c 2 weeks ago 188 MB Registry 2 88ecdbb5a90 8 2 weeks ago 171.1 MB Swarm latest 0f1a3829719c 2 weeks AG
o 18.71 mb MySQL 5.6 f2e8d6c772c0 2 weeks ago 324.6 MB Haproxy Latest 55FC47C91E3B 3 weeks ago 139 MB Nginx 1.9 eb4a127a1188 3 weeks ago 182.7 MB Django Latest f9dac91871 3 weeks ago 451 MB Ubuntu 15.10 4e3b13c8a266 4 weeks ago 136.3 MB Redis latest 4f5f397d4b7c 8 weeks ago 177.6 MB R Egistry 2.3.0 5eaced67751b 8 weeks ago 165.7 MB Google/cadvisor Latest a56e3f67a48d 9 weeks ago 46.33 MB Registry Lates T bca04f698ba8 3 months ago 422.9 MB Golang 1.5.1 e62a BE1305A5 5 months ago 709.3 MB Sequenceiq/hadoop-docker latest 5C3CC170C6BC 9 m Onths ago 1.766 GB
2. Save the image as a tar file via the Docker Save command
root@controller:~# Docker save-o/root/google-cadvisor.tar google/cadvisor root@controller:~# ls admin-openrc.sh Docker Google-cadvisor.tar Pipework root@controller:~# ll Total 46312 drwx------8 root root 4096 May 3 11:20./d Rwxr-xr-x root root 4096 Apr 14 10:53. /-rw-r--r--1 root root 135 Apr 10:35 admin-openrc.sh-rw-------1 root root 37672 Apr 17:39. bash_histor y-rw-r--r--1 root root 3106 Feb. bashrc drwx------2 root root 4096 Apr 16:10. cache/drwxr-xr-x 2 root root 4096 Apr 22:36 docker/-R--------1 root root one 00:00. erlang.cookie-rw-------1 root Root 47311360 May 3 11:20 google-cadvisor.tar-rw-------1 root root 1727 Apr 11:50. Mysql_history drwxr-xr-x 3 root root 4096 Apr 10:54. novaclient/drwxr-xr-x 4 root root 4096 Apr 10:37 pipework/-rw-r--r--1 root ro OT. Profile drwx------2 root root 4096 Apr 16:10. Ssh/drwxr-xr-x 2 Root Root 4096 Apr 17:01. vim/-rw-------1 root root 11959 Apr 17:01. viminfo
Once saved as a tar file, we can copy the file to the 192.168.13.120 container environment in a physical form.
1. View the image list of the target environment
root@controller:~# Docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu Latest b1e98eb57559 7 days ago 120.1 MB
ubuntu/pipework latest a161cd7260da 7 days ago 226 MB
ubuntu/mysql latest 62b80c65d15b 4 months ago 373.3 MB
Ubuntu/os Latest 39eea0e53d4e 5 months ago 653.2 MB
ubuntu 14.04 1d073211c498 6 Months ago 187.9 mb
ubuntu 14.04.3 1d073211c498 6 months ago 187.9 MB
Ubuntu 12.04 0ac5b09d8536 6 months ago 136.1 MB
tutum/ubuntu latest 151c4704c045 months ago 251.5 MB
training/sinatra latest f0f4ab557f95 at months ago 447 MB
2. Load the tar file through the Docker load command
root@controller:~# ls AKSUSBD docker-static-ip-master master.zip Sinatra supermapicloudmanager7c Dockerfile Google-cadvisor.tar Pipework-master supermap_icloud_711_30278_255_linux64.tar.g Z supermapiserver root@controller:~# Docker load-i/root/google-cadvisor.tar root@controller:~# Docker images REPOSITOR Y TAG IMAGE ID CREATED VIRTUAL SIZE Ubuntu Latest b1e98eb57559 7 days ago 120.1 MB ubuntu/pipework latest a161cd7260da 7 days ago 226 MB Google/cadvisor Latest 77ab3045082e 9 weeks ago 46.33 MB Ubuntu/mysql Latest 62b80c65d15b 4 months ago 373.3 MB Ubuntu/os latest 39eea0e53d 4e 5 months ago 653.2 MB Ubuntu 14.04 1d073211c498 6 months ago 187 .9 MB Ubuntu14.04.3 1d073211c498 6 months ago 187.9 MB Ubuntu 12.04 0ac5b09d8536 6 months ago 136.1 MB Tutum/ubuntu latest 151c4704c045 ten months ago 251.5
MB training/sinatra latest f0f4ab557f95 months ago 447 MB
We can see that the google/cadvisor image has been loaded in and then started.
root@controller:~# Docker run \ >--volume=/:/rootfs:ro \ >--VOLUME=/VAR/RUN:/VAR/RUN:RW \ >--volume=/sys:/sys:ro \ >--volum E=/var/lib/docker/:/var/lib/docker:ro \ >--publish=8080:8080 \ >--detach=true \ >--name=cadvisor \ > Google/cadvisor:latest 046ad9524cc9 A92f118869aae7d10f04c6dfb6e215051f07ea47a5a91ea34e22 root@controller:~# Docker ps-a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 046ad9524cc9 Google/cadvisor:latest "/usr/bin/cadvisor-l" seconds ago up to seconds 0.0.0.0:8080->8080/tcp CA Dvisor 54fd72ea7832 ubuntu:14.04 "/bin/bash" 5 days ago up 2 hours Test1
Summarize
In this simple way, we can backup, restore, migrate (backup and restore) of Docker images, instances, which is very convenient for our Docker exchange.