Transferring Docker images between machines is a common task—especially when you’re working in air-gapped environments, internal networks, or want to avoid using public or private Docker repositories.
In this blog post, you’ll learn how to copy Docker images from one host to another without using Docker Hub or any external repository, using the docker save
and docker load
commands.
🧠 Why Copy Without a Repository?
You may want to skip pushing to Docker Hub (or any registry) for reasons like:
- No internet access on the target machine
- Security or policy restrictions
- Faster transfer within a local network
- Avoiding Docker login hassles
✅ Step-by-Step: Export and Import a Docker Image
🔧 Step 1: Save the Image on the Source Host
On the source machine, save the Docker image to a .tar
file using docker save
.
docker save -o my-image.tar <image-name>:<tag>
Example:
docker save -o my-app.tar my-app:latest
💡 The
-o
flag specifies the output file name. The file can be large depending on the image size.
🔧 Step 2: Transfer the Image File
Now, copy the image file (my-app.tar
) to the target machine using any file transfer method:
scp
for SSH transfer:scp my-app.tar user@remote-host:/home/user/
- USB drive or external disk
- File share, FTP, etc.
🔧 Step 3: Load the Image on the Target Host
Once the file is on the target host, import it using docker load
:
docker load -i my-app.tar
This will load the image into the local Docker engine. You can now run it as usual:
docker run my-app
✅ Bonus: List Available Images
After loading the image, you can verify it with:
docker images
🧪 Optional: Compress the Image Before Transfer
To save bandwidth or disk space, you can compress the image file:
docker save my-app:latest | gzip > my-app.tar.gz
And decompress it on the target:
gunzip my-app.tar.gz
docker load -i my-app.tar
✅ Summary
Action | Command Example |
---|---|
Save image to tar file | docker save -o my-app.tar my-app:latest |
Transfer to another machine | scp my-app.tar user@target:/path |
Load image from tar on target | docker load -i my-app.tar |
🚀 Final Thoughts
You don’t need Docker Hub or any registry to share Docker images between hosts. With docker save
and docker load
, you can easily export and import images using standard tools like scp
, USB drives, or shared folders.
🔐 Tip: If you’re moving production images, always verify integrity with a checksum (e.g.,
sha256sum
) before loading them on the destination host.