How to copy Docker Images to Another Host?
Sometimes you might need to copy your docker container image to another docker Host. One way is to commit the image to a Private or Public Docker Repository and on the second host, run the “docker pull ” command. This will work most of the times, but if you dont have a private docker registry, you will have to look for other options.
Docker has “save” feature which is used to persist an image. First we need to get the Docker image ID .
Use the following command to see the image ID
To save one image
docker save myimage-1 > /home/myimage-1.tar
This command will save the image to tar archive /home/myimage-1.tar
Now we can copy this tar file to destination using any of the linux tools like “scp” or “rsync”.
To load this image to Docker on Destination Host
Run the following command
docker load < /home/myimage-1.tar
This will take few seconds depending on the image size. Once the command finished, we can verify the image is loaded to Docker on new server , by running the following command
# check the available images
The Image “myimage-1” should be listed in the output. Please see the image below
You can see the image “myimage-1” listed .
Now we can start container using these images.
This way we copied docker image to another host without using Docker registry. There is one more feature called “export” , this is used to persist the running containers (not images). This feature also allows us to create tar archive of the running container , but we will loss the history of the particular image.