How to save and load docker images

These days Im developing cartridges for apache stratos. which is design and developed by WSO2 Inc. This PAAS environment lately donated to apache foundation. Since i develop these cartridges using a vm i needed to create a backup of generated images after googling i found a way to save my images as a tar archive.

stratos@Dev-PC:~$ docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
couchdb-cartridge                      latest              7ebc8510bc2c        17 hours ago        1.102 GB
192.168.57.30:5042/couchdb-cartridge   latest              7ebc8510bc2c        17 hours ago        1.102 GB
ubuntu                                 14.04               53bf7a53e890        3 days ago          221.3 MB


Save the archiveName image to a tar file. I will use the /media/sf_docker_vm/ to save the image.

stratos@Dev-PC:~$ docker save imageID > /media/sf_docker_vm/archiveName.tar

Copy the archiveName.tar file to your new Docker instance using whatever method works in your environment, for example FTP, SCP, etc.

Run the docker load command on your new Docker instance and specify the location of the image tar file.

stratos@Dev-PC:~$ docker load < /media/sf_docker_vm/archiveName.tar


Finally, run the docker images command to check that the image is now available.


stratos@Dev-PC:~$ docker imagesREPOSITORY                             TAG                 IMAGE ID            CREATED             VIRTUAL SIZEcouchdb-cartridge                      latest              7ebc8510bc2c        17 hours ago        1.102 GB192.168.57.30:5042/couchdb-cartridge   latest              7ebc8510bc2c        17 hours ago        1.102 GBubuntu                                 14.04               4d2eab1c0b9a        3 days ago          221.3 MB

Comments