How to Copy Docker Images from One Host to Another Without Using a Repository

Sometimes, you need to move Docker images between systems—such as from development to staging, or from a restricted environment to a production server—without using Docker Hub or a private registry.

In this guide, you’ll learn how to copy Docker images from one host to another manually using docker save and docker load. This method works great in air-gapped or offline environments.


🧰 Use Case Examples

  • Migrating images between offline machines
  • Avoiding registry usage due to security or policy restrictions
  • Faster local transfers during development

🪛 Step-by-Step Guide

✅ 1. Save the Docker Image to a Tar File

On the source host, first identify the image you want to export:

docker images

Then, save the image to a .tar archive:

docker save -o my-image.tar my-image:tag

Example:

docker save -o nginx-custom.tar nginx:custom

This command creates a portable .tar file containing the image and all its layers.


🔄 2. Transfer the .tar File

Now copy the .tar file to your target host using any file transfer method:

  • SCP:
scp my-image.tar user@remote-host:/path/to/destination
  • USB drive or shared folder

📦 3. Load the Image on the Target Host

Once the file is on the target host, import it into Docker:

docker load -i my-image.tar

You’ll see something like:

Loaded image: nginx:custom

Now you can use it like any other image:

docker run -it nginx:custom

🧼 Optional: Compress for Smaller Transfer Size

You can compress the archive before transfer:

docker save my-image:tag | gzip > my-image.tar.gz

And then decompress + load on the other side:

gunzip -c my-image.tar.gz | docker load

🔐 Bonus: Validate Image After Transfer

To ensure the image was transferred successfully, you can compare image IDs:

docker inspect --format='{{.Id}}' my-image:tag

Do this on both source and destination hosts.


📋 Summary

TaskCommand
Save imagedocker save -o image.tar image:tag
Load imagedocker load -i image.tar
Compress imagedocker save image:tag | gzip > image.tar.gz
Decompress & loadgunzip -c image.tar.gz | docker load

🚀 Final Thoughts

Using docker save and docker load is a reliable and secure way to move images between machines without a registry. It’s ideal for offline environments, quick backups, or when dealing with restricted network setups.

Want to automate this process across multiple environments? Consider scripting the save/load steps as part of your deployment workflow.

Sharing Is Caring:

Leave a Comment