Skip to content
Go back

How to Transfer docker Images Without a Repository

· Updated:
By KingPin 7 min read
How to Transfer docker Images Without a Repository
Contents

Copy Docker Images from One Host to Another Without a Repo

Docker is a powerful platform for developing, shipping, and running applications inside lightweight containers. This article will guide you through the process of transferring Docker images from one host to another without the need of a repository. This can be particularly useful in environments where security concerns prohibit the use of public repositories, or in cases where network constraints make repository access impractical.

Table of Contents

Open Table of Contents

1. Introduction

Docker images are made up of layers of files that represent instructions in the Dockerfile that was used to create them. Normally, these images are stored and shared through Docker registries like Docker Hub. However, there are scenarios where direct image transfer between hosts is needed. Two primary methods handle this.

2. Prerequisites

Before proceeding, ensure you have the following:

sudo apt-get update
sudo apt-get install docker.io

3. Method 1: Using docker save and docker load

This method involves saving the Docker image as a tar archive on the source host and then transferring this archive to the destination host where it can be loaded into Docker.

Step-by-Step Guide

On the Source Host:

docker save -o myimage.tar myimage:tag

Replace myimage:tag with the name and tag of your Docker image.

scp myimage.tar user@destination-host:/path/to/destination

Replace user@destination-host with the appropriate user and hostname/IP address of the destination host.

On the Destination Host:

docker load -i /path/to/destination/myimage.tar

Advantages and Disadvantages

4. Method 2: Using docker export and docker import

This method involves exporting a container (not an image) to a tar file, transferring it, and then importing it as an image on the destination host.

Step-by-Step Guide

On the Source Host:

docker create --name mycontainer myimage:tag

Then export it to a tar file.

docker export mycontainer -o mycontainer.tar

On the Destination Host:

docker import /path/to/destination/mycontainer.tar mynewimage:tag

Advantages and Disadvantages

5. Considerations for Secure Transfer

When transferring Docker images between hosts, consider the following to enhance security:

6. Conclusion

Transferring Docker images between hosts without a repository is straightforward using the methods described above. Whether you choose docker save and docker load or docker export and docker import, each method has its own advantages depending on your specific needs. Always consider security implications during the transfer process to protect your data.

By understanding these techniques, you can efficiently manage Docker images in environments where using a traditional repository is not feasible.

Compress on the Fly to Save Time (and Sanity)

One thing nobody tells you until you’re watching a 4 GB tar crawl over a VPN at 2 AM: uncompressed tars are painful to move. A base Python or Node image can balloon to 1 to 2 GB uncompressed. You can pipe directly through gzip instead of saving a raw tar first.

Terminal window
# Save + compress in one shot on the source host
docker save myimage:tag | gzip > myimage.tar.gz
# Transfer the compressed file
scp myimage.tar.gz user@destination-host:/tmp/
# Load it on the destination — docker load handles gzip transparently
ssh user@destination-host "docker load -i /tmp/myimage.tar.gz"

Typical compression ratios are 40 to 60% for most images, so a 1.5 GB tar becomes ~600 to 800 MB. That’s real time savings, especially on slow links.

Multi-image bundles

If you need to move several images at once, say you’re migrating a full Compose stack, docker save takes multiple image names in one shot:

Terminal window
docker save myapp:latest nginx:alpine postgres:16 | gzip > stack-images.tar.gz

One file, one transfer, all images. Load it the same way on the other side.

The gotcha nobody hits until they hit it

docker load restores images exactly as they were tagged on the source. If you saved myapp:latest and the destination already has a myapp:latest pointing to a different image ID, Docker will untag the old one (it becomes <none>:<none>). That’s not an error, it’s just Docker being Docker. Check docker images after loading and clean up any dangling images with docker image prune if things look messy.

Also worth noting: docker export/import strips multi-stage build metadata and layer history. If you need to rebuild from that image or inspect its layers later, stick with docker save/load, it preserves everything.

Common Questions

Can I copy a Docker image to another server without a registry?

Yes. Run docker save -o myimage.tar myimage:tag on the source host, copy the tar file with scp, and run docker load -i on the destination host. Docker needs no registry for this.

What is the difference between docker save and docker export?

Use docker save and docker load when you want the image as it was. Docker keeps the image history, metadata, and tags with that method. The docker export and docker import pair works on a container, not an image, so docker export saves only the current filesystem state and drops history and metadata. The result can be smaller, but the layer history is gone. Stick with docker save and docker load if you need to rebuild from the image or inspect its layers later.

How do I move several Docker images in one file?

List every image name in one docker save command and pipe the output through gzip, for example docker save myapp:latest nginx:alpine postgres:16 | gzip > stack-images.tar.gz. You copy one file and run docker load -i once on the other side. docker load reads the gzip file without a separate decompress step.

What happens if the image tag already exists on the destination host?

Docker untags the old image and points the tag at the loaded one. The old image becomes <none>:<none>, and Docker raises no error. Run docker images after the load to check, then run docker image prune to clear the dangling images.


Wrote about this post on your own site? Send a webmention.

It shows up above once verified.


Previous Post
Docker Volume Mounts: Essential Flags
Next Post
Copying Files Between Docker Containers and Host Machines

Discussion

Powered by Garrul. Sign in with GitHub or Google, or post anonymously.

Related Posts