Question

How to copy a Docker image from one server to another without pushing it to a repository first?

In some cases, you might not want to push a Docker image over to Docker Hub or a private Docker repository.

Here is how you could transfer a Docker image from one server to another without pushing the image to an external Docker repository!


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
December 1, 2020
Accepted Answer

In order to transfer a Docker image from one server to another, what you need to do is first export the image to a file, then copy that file over from your current server to the new one using scp or rsync and finally load the image to your new server. Here’s how to do that:

  • First SSH to your server where you’ve got your Docker image currently stored at and then run the following command to generate the tar file:
  1. sudo docker save -o /home/sammy/your_image.tar your_image_name
  • This will create a tar file of your image and store it at the /home/sammy/your_image.tar folder. You can check the size of the file with the ls command:
  1. ls -lah /home/sammy/your_image.tar
  • Once you have your Docker image ready, you need to copy it over using rsync, scp, or SFTP using Filezilla for example. My personal favorite is rsync. If you are not familiar with rsync, I strongly suggest going through this tutorial here on how to use rsync:

https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories

In case that you decide to use rsync as well, to copy the file over run the following command:

rsync -avz /home/sammy/your_image.tar username@remote_server_ip_address:destination_directory

Note: make sure to chagne the destination_directory, the username and the remote_server_ip_address with your actual details

  • Once you have your .tar file copied over to your new server, SSH to the new server and load the Docker image:
  1. sudo docker load -i your_image.tar
  • Then, in order to check if this was successful, you can run docker images to see the list of the available images:
  1. sudo docker images

Here is a quick video demo on how to do the above as well:

This is pretty much it! I hope that it helps! Regards, Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel