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.
I want to move all images with tags.
Explanation:
First
OUT
gets all tags but separated with new lines. SecondOUTPUT
gets all tags in an array. Third$(echo "${OUTPUT[*]}")
puts all tags for a singledocker save
command so that all images are in a single tar.Additionally, this can be zipped using gzip. On target, run:
-O
option totar
puts contents on stdin which can be grabbed bydocker load
.docker-push-ssh
is a command line utility just for this scenario.It sets up a temporary private Docker registry on the server, establishes an SSH tunnel from your localhost, pushes your image, then cleans up after itself.
The benefit of this approach over
docker save
(at the time of writing most answers are using this method) is that only the new layers are pushed to the server, resulting in a MUCH quicker upload.Oftentimes using an intermediate registry like dockerhub is undesirable, and cumbersome.
https://github.com/coherenceapi/docker-push-ssh
Install:
Example:
docker-push-ssh -i ~/my_ssh_key username@myserver.com my-docker-image
The biggest caveat is that you have to manually add your localhost to Docker's
insecure_registries
configuration. Run the tool once and it will give you an informative error:Where should I set the '--insecure-registry' flag on Mac OS?
I assume you need to save
couchdb-cartridge
which has an image id of 7ebc8510bc2c:Save the archiveName image to a tar file. I will use the
/media/sf_docker_vm/
to save the image.Copy the archiveName.tar file to your new Docker instance using whatever method works in your environment, for example
FTP
,SCP
, etc.Run the
docker load
command on your new Docker instance and specify the location of the image tar file.Finally, run the
docker images
command to check that the image is now available.Please find this detailed post.
All other answers are very helpful. I just went through the same problem and figure out an easy way with
docker machine scp
.Since Docker Machine v0.3.0, scp was introduced to copy files from one Docker machine to another. This is very convenient if you want copying a file from your local computer to a remote Docker machine such as AWS EC2 or Digital Ocean because Docker Machine is taking care of SSH credentials for you.
Save you images using
docker save
like:Copy images using docker-machine scp
Assume your remote Docker machine is
remote-machine
and the directory you want the tar file to be is/home/ubuntu
.Load the Docker image
Run
to see a list of the images on the host. Let's say you have an image called awesomesauce. In your terminal,
cd
to the directory where you want to export the image to. Now run:Copy the tar file to a thumb drive or whatever, and then copy it to the new host computer.
Now from the new host do:
Now go have a coffee and read Hacker News...
For a flattened export of a container's filesystem, use;
docker export CONTAINER_ID > my_container.tar
Use
cat my_container.tar | docker import -
to import said image.