How to copy docker images from one host to another without via repository?
How to transfer docker image from one machine to another one without using a repository, no matter private or public?
I am used to play and 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 own based image (like redhat), it cannot be recreated from Dockerfile.
Are there any simple commands I can use? Or another solution?
Updated It seems save/export can achieve similar purpose, see What is the difference between save and export in Docker?, and I prefer the save
command for my case.
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 cp
or scp
. 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.
Transferring a Docker image via SSH, bzipping the content on the fly:
docker save <image> | bzip2 |
ssh user@host 'bunzip2 | docker load'
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 user@host 'bunzip2 | docker load'
To save image to any file path or shared nfs see following example.
Get image id by doing:
sudo docker images
Say you have image with id "matrix-data"
Save image with id:
sudo docker save -o /home/matrix/matrix-data.tar matrix-data
Copy image from path to any host Now import to your local docker using :
sudo docker load -i <path to copied image file>
Hope this make make more clear.
Thanks
链接地址: http://www.djcxy.com/p/3012.html