Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
How to copy Docker images from one host to another without using a repository?
Docker images can be transferred from one host to another without using a repository like Docker Hub. While pushing to a registry is the standard approach, there are several alternative methods that allow direct image transfer between machines without creating accounts or managing repositories.
These methods are particularly useful for offline environments, private networks, or when you need to quickly share images without internet access. Let's explore the most effective techniques for copying Docker images directly between hosts.
Method 1 − Saving and Loading from TAR Files
Docker provides built-in commands to export images as compressed TAR archives. This method creates a portable file that can be easily transferred and restored on any Docker-enabled machine.
Step 1: Save the Image
docker save -o myimage.tar myimage:latest
Step 2: Transfer the TAR File
Copy the TAR file using any file transfer method −
scp myimage.tar user@remotehost:/tmp/
Step 3: Load the Image on Destination Host
docker load -i /tmp/myimage.tar
Method 2 − Direct Transfer via SSH with Compression
This method combines saving, compression, and transfer in a single command using SSH pipes. The bzip2 compression reduces transfer time significantly.
docker save myimage:latest | bzip2 | ssh user@remotehost 'bunzip2 | docker load'
To monitor transfer progress, add pv (pipe viewer) −
docker save myimage:latest | bzip2 | pv | ssh user@remotehost 'bunzip2 | docker load'
Method 3 − Docker Machine Transfer
When using Docker Machine to manage multiple Docker hosts, you can pipe images directly between machines −
docker $(docker-machine config source-machine) save myimage:latest | docker $(docker-machine config target-machine) load
Method 4 − Using DOCKER_HOST Environment Variable
This method leverages SSH to connect to remote Docker daemons directly. Both users must be in the docker group on their respective machines.
docker save myimage:latest | gzip | DOCKER_HOST=ssh://user@remotehost docker load
Method 5 − Docker-push-ssh Utility
The docker-push-ssh tool creates a temporary private registry on the target host and transfers only new layers, making it faster for incremental updates.
Installation
pip install docker-push-ssh
Usage
docker-push-ssh -i ~/ssh-key username@remotehost myimage:latest
Method 6 − Docker Machine SCP
Docker Machine's scp command simplifies file transfer to cloud-based Docker hosts by handling SSH credentials automatically.
Step-by-Step Process
Step 1: Save the image locally −
docker save -o myimage.tar myimage:latest
Step 2: Transfer using Docker Machine SCP −
docker-machine scp ./myimage.tar target-machine:/tmp/
Step 3: Load on the remote machine −
docker-machine ssh target-machine sudo docker load -i /tmp/myimage.tar
Comparison of Methods
| Method | Best For | Compression | Speed |
|---|---|---|---|
| TAR Files | Offline transfer | Optional | Moderate |
| SSH Pipes | Online transfer | Built-in | Fast |
| Docker-push-ssh | Incremental updates | Layer-based | Very Fast |
| Docker Machine | Cloud environments | Optional | Moderate |
Conclusion
These six methods provide flexible options for transferring Docker images without repositories. Choose TAR files for offline scenarios, SSH pipes for direct online transfer, or docker-push-ssh for efficient incremental updates. Each method suits different network conditions and infrastructure requirements.
