Saturday 3 September 2016

Docker - Moving Images between Servers

Another in the series of Docker-flavoured articles.

I am using Docker on MacOS, and had a requirement to move an image from one host to another.

In terms of Docker version, I'm using the native version ( rather than Boot2Docker, VirtualBox etc. ) : -

docker version

Client:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      darwin/amd64

Server:
 Version:      1.12.0
 API version:  1.24
 Go version:   go1.6.3
 Git commit:   8eab29e
 Built:        Thu Jul 28 21:15:28 2016
 OS/Arch:      linux/amd64


and wanted to move an image from one Mac ( Mini ) to another ( MacBook Pro ).

I had an IBM Operational Decision Manager (ODM) image: -

docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
odm88               latest              f2af5a4e07f7        2 hours ago         850.4 MB
websphere-liberty   webProfile7         0adb796da35d        3 weeks ago         396 MB
websphere-liberty   8.5.5               40d6ee83cbcd        12 weeks ago        450.6 MB

which I wanted to move.

First, I backed up the image: -

docker save odm88 > odm88.tar

and copied it onto a USB drive.

I then validated the image: -

ls -al odm88.tar

-rw-------  1 davidhay  staff  863003136  3 Sep 19:58 /Volumes/DaveHaySSD/odm88.tar

and then imported it: -

docker load < /Volumes/DaveHaySSD/odm88.tar 

9436069b92a3: Loading layer [==================================================>] 127.6 MB/127.6 MB
fac4a4c59f33: Loading layer [==================================================>] 408.6 kB/408.6 kB
8bcab4108495: Loading layer [==================================================>] 11.78 kB/11.78 kB
30abc4102690: Loading layer [==================================================>] 4.608 kB/4.608 kB
f22c53c9839e: Loading layer [==================================================>]  8.72 MB/8.72 MB
c91c23c14c4b: Loading layer [==================================================>] 172.6 MB/172.6 MB
ddf3edca49d4: Loading layer [==================================================>]  18.7 MB/18.7 MB
6172eb053c2f: Loading layer [==================================================>]  2.56 kB/2.56 kB
f1902d30b668: Loading layer [==================================================>] 11.78 kB/11.78 kB
fd69f0985569: Loading layer [==================================================>] 38.06 MB/38.06 MB
dad70715c572: Loading layer [==================================================>] 5.632 kB/5.632 kB
fde07fb5cc84: Loading layer [==================================================>] 3.584 kB/3.584 kB
10a71cc5df6c: Loading layer [==================================================>] 46.04 MB/46.04 MB
fa5ee85b0069: Loading layer [==================================================>] 6.656 kB/6.656 kB
55550d7ccc3a: Loading layer [==================================================>] 49.95 MB/49.95 MB
f1148208b8f2: Loading layer [==================================================>] 2.844 MB/2.844 MB
36c86a388a47: Loading layer [==================================================>] 35.52 MB/35.52 MB
5376943f12c1: Loading layer [==================================================>] 362.4 MB/362.4 MB
eb8dbc394155: Loading layer [==================================================>] 11.26 kB/11.26 kB
Loaded image ID: sha256:f2af5a4e07f7f0088250a54812b02d0ba95493adaa64ff657b200c1e3ff63a1d
I then validated the image repository: -

docker images

REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
<none>                <none>              f2af5a4e07f7        2 hours ago         850.4 MB
ibmcom/datapower      latest              e8cc082c4c80        42 hours ago        719.2 MB
jenkins               2.7.2               a94b49bb279b        2 days ago          714.5 MB
websphere-liberty     latest              f042ad3a168c        3 weeks ago         444.4 MB
websphere-liberty     webProfile7         efa42bcc5850        3 weeks ago         396 MB
ibmcom/db2express-c   latest              7aa154d9b73c        15 months ago       1.705 GB

Notice that the image that I've restored has the right ID ( f2af5a4e07f7 ) and size ( 850.4 MB ) *BUT* the repository and tag details have been lost :-(

This is easily fixed …

docker tag f2af5a4e07f7 odm88:latest

docker images

REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
odm88                 latest              f2af5a4e07f7        2 hours ago         850.4 MB
ibmcom/datapower      latest              e8cc082c4c80        42 hours ago        719.2 MB
jenkins               2.7.2               a94b49bb279b        2 days ago          714.5 MB
websphere-liberty     latest              f042ad3a168c        3 weeks ago         444.4 MB
websphere-liberty     webProfile7         efa42bcc5850        3 weeks ago         396 MB
ibmcom/db2express-c   latest              7aa154d9b73c        15 months ago       1.705 GB

which is nice :-)

For reference, here's the Dockers docs :-)

Docker save command
Docker load command

No comments:

Visual Studio Code - Wow 🙀

Why did I not know that I can merely hit [cmd] [p]  to bring up a search box allowing me to search my project e.g. a repo cloned from GitHub...