Description
You need to copy Docker images from one host to another for various reasons. In this case, using a public or private registry is typically the first option. For instance, you can push your image to a repository in Docker Hub. But you must have a Docker Hub account. Then you need to tag the image and push it to the repo. Now, you should go to the machine you want to move. With the docker pull command, download your image from the Docker Hub repo to that host machine. As you see, it is a long haul. But what if we don’t want to use a repository? I will show you how to cut corners.
Copy Docker images from one host to another by tar files
The most common and robust method is saving and loading images from tar files. Docker allows you to save images into tar files using the docker save
. This command also compresses images and enables sharing them easily and quickly. You can then use the docker load
command to load the Docker image back from the tar file into another host. It is that much easy to copy Docker images from one host to another without using a repository.
First of all, let’s check the existed images by running docker images
:

To export the alpine image to a tar file, run the docker save -o <tar file path in source host machine> <image_name>
command, specifying a name for the .tar file, and the docker image. This will save the docker image locally.

Next, copy your image to your target system. You could use scp or another file transfer tool such as rsync. Then we will connect to the remote machine which is another host via ssh.

When I check the destination path of the tar file which we sent, alpiner.tar has already been there. So transferring the tar file of the image is successfully completed. Now let’s list the images on this host to see whether alpine images exist or not there.

As you see above, there is no image on the target host because we have not imported the image yet. The docker load -i <image.tar>
command will load the docker image from the tar file.

As a last option, you can also use another tool called Skopeo, which we published an introduction post about that earlier. Checkout from this link.
Skopeo can help you to sync or move images.
Conclusion
To sum up, we learn how to copy Docker images from one host to another without using any Docker registry or repository. In between, either with the help of docker save/docker load command pair or with another tool called Skopeo are offered.
Let us know if you are using other methods or tools to accomplish this task.
Thanks.