The best answers to the question “How to copy Docker images from one host to another without using a repository” in the category Dev.
How do I transfer a Docker image from one machine to another one without using a repository, no matter private or public?
I create my own image in VirtualBox, and when it is finished I try to deploy to other machines to have real usage.
Since it is based on my own based image (like Red Hat Linux), it cannot be recreated from a Dockerfile. My dockerfile isn’t easily portable.
Are there simple commands I can use? Or another solution?
Transferring a Docker image via SSH, bzipping the content on the fly:
docker save <image> | bzip2 | ssh [email protected] docker load
docker load automatically decompresses images for you. It supports
It’s also a good idea to put
pv in the middle of the pipe to see how the transfer is going:
docker save <image> | bzip2 | pv | ssh [email protected] docker load
(More info about
pv: home page, man page).
Important note from @Thomas Steinbach: on high bandwidth,
bzip won’t be able to compress fast enough. In case you can upload at 10 MB/s and more,
gunzip will be much faster than
If you’re on 3G and your Internet is slow, @jgmjgm suggests that you can use
xz: it offers a higher compression ratio.
You will need to save the Docker image as a tar file:
docker save -o <path for generated tar file> <image name>
Then copy your image to a new system with regular file transfer tools such as
rsync(preferred for big files). After that you will have to load the image into Docker:
docker load -i <path to image tar file>
PS: You may need to
sudo all commands.
You should add filename (not just directory) with -o, for example:
docker save -o c:/myfile.tar centos:16
You can use a one-liner with
docker save app:1.0 | gzip | DOCKER_HOST=ssh://[email protected] docker load
To save an image to any file path or shared NFS place see the following example.
Get the image id by doing:
Say you have an image with id “matrix-data”.
Save the image with id:
docker save -o /home/matrix/matrix-data.tar matrix-data
Copy the image from the path to any host. Now import to your local Docker installation using:
docker load -i <path to copied image file>