In our previous tutorials you have learned about installation of Docker engine on CentOS/RHEL and Ubuntu operating system and pulled images from Docker hub. After that created containers with images. This tutorial will help you to export and import Docker images and move them between hosts.

List Docker Images

Fist list docker images on your system using below command.

[email protected]:~# docker images

centos         latest     2933d50b9f77        11 days ago      196.6 MB
ubuntu         latest     36248ae4a9ac        11 days ago      188 MB

Save or Archive Image

Now use the following command to save image repository named ubuntu (image id: 36248ae4a9ac) and make a zipped archive named ubuntu-latest.tar.gz. Remember that save is used for making backup of docker images (not containers).

# docker save ubuntu | gzip > ubuntu-latest.tar.gz

Import Image

After saving docker image in archive format on your system move it to remote system using scp or ftp. After that use below command on remote system to import Docker image with name ubuntu and tag name latest.

# zcat ubuntu-latest.gz | docker import - ubuntu:latest

The above command will create a docker image with name ubuntu and tag name latest on your system. You can now launch containers using this image like below.

# docker run -i -t ubuntu /bin/bash