In our previous post, we saw that how could we install and work on Docker container in Ubuntu and CentOS/Redhat distributions.Docker_docs now we know how to pulled images from Docker Hub and work on them. we should also know how to move Docker images from one working host to another host. So that we could skip the internet pull every time and also can save our configuration into new images and move them to another host for the same application.


In this post we would work on CentOS6.9 Linux machine with one fedora docker image. we will see how could we take backup of it and restore it on another Host.

[root@srv3 ~]# cat /etc/redhat-release
CentOS release 6.9 (Final)

[root@srv3 ~]# docker images fedora
fedora       latest   0c462a372ed0    5 months ago    230.3 MB

Save Docker Image

Now we have fedora image in the machine that has some changes in course of time which used to work in a certain manner which was worked to deploy an application and I like to move the same image in another host and use it in the same manner.
Let's start how to take a backup of Docker image...

# docker save fedora | gzip > fedora.tar.gz

This command will create fedora.tar.gz command, this file contains docker image. which could move and restore on another Host machine.

Restore or Import Image

Now its time to resore and work on Host with this image. SO we have to move this image on another Host. in my case both machine has same network So i used scp command to copy data. and Import fedora Docker image.

root@srvU:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
root@srvU:~# zcat fedora.tar.gz | docker import - fedora
root@srvU:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
fedora              latest              3e0882ed3c66        7 seconds ago       240 MB

Now we could run this image to work on.

# docker run -it fedora /bin/bash
[root@ccf80e78a743 /]#