How do I transfer a 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 Red Hat Linux), it cannot be recreated from a Dockerfile.
Are there simple commands I can use? Or another solution?
It seems save/export can achieve a similar purpose, see What is the difference between save and export in Docker?, and I prefer the save
command for my case.
When using docker-machine, you can do
docker $(docker-machine config <mach1>) save <image> | docker $(docker-machine config <mach2>) load
to copy images between machinesmach1
andmach2
.And of course you can also stick
pv
in the middle to get a progess indicator:docker $(docker-machine config <mach1>) save <image> | pv | docker $(docker-machine config <mach2>) load
.You may also omit one of the
docker-machine config
sub-shells, to use your current default docker-host.docker save <image> | docker $(docker-machine config <mach>) load
to copy image from current docker-host tomach
or
docker $(docker-machine config <mach>) save <image> | docker load
to copy frommach
to current docker-host.This is how you can move Docker images between two remote registers/repositories. It works with Docker version 1.10.2, build c3959b1.
It's a handy method if you want to migrate your images to an AWS ECS/ECR service.
First save the Docker image to a zip file:
Then load the exported image to Docker using the below command:
To transfer images from your local Docker installation to a minikube VM:
Transferring a Docker image via SSH, bzipping the content on the fly:
It's also a good idea to put
pv
in the middle of the pipe to see how the transfer is going:(More info about
pv
: home page, man page).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:
Copy the image from the path to any host. Now import to your local Docker installation using: