How to save all Docker images and copy to another machine

docker save
docker save vs export
docker load
docker copy image to another directory
push docker image to remote server
docker how to copy an image
docker load vs import
copy docker image from one registry to another

I have the below list of images present on my system and want to copy all these images to a remote machine.

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
u14_py269           latest              6a1ec0b508b3        4 days ago          885.9 MB
u12_py273           latest              c2a804894851        4 days ago          686 MB
u12_core            latest              0d61eba80df2        4 days ago          629.1 MB
c6_py266            latest              cb1a94742d59        4 days ago          1.32 GB
c6_core             latest              77c2ed19d87f        4 days ago          1.278 GB
c7_py275            latest              bb1d3de68452        4 days ago          1.117 GB
c7_core             latest              ca14a76e9cca        4 days ago          1.081 GB
u14_py35            latest              d110c7e4a1f5        5 days ago          914.5 MB
u14_py34            latest              085a37cb8614        5 days ago          830.7 MB
u14_py276           latest              8927c6167930        5 days ago          834.1 MB
u14_core            latest              93ead5abc25b        5 days ago          776.9 MB
centos              centos6             36877b5acebb        5 days ago          228.9 MB
ubuntu              latest              36248ae4a9ac        5 days ago          188 MB
ubuntu              12.04               94a7cb19a65b        5 days ago          137.8 MB
edgester/gerrit     latest              ce4e3238052a        6 days ago          735.2 MB
u14_as374_py276     latest              fa5fb7189d70        11 days ago         1.497 GB
c721_as373_py275    latest              03ccf6961d0c        11 days ago         844.3 MB
c721_as373_py35     latest              b5fece3dd45b        11 days ago         1.127 GB
c171_con_core       latest              8af0d24a38a0        2 weeks ago         377.2 MB
u14_as374_php55     latest              29df638e363a        3 weeks ago         1.073 GB
j_u14_as374_php55   latest              29df638e363a        3 weeks ago         1.073 GB
centos              centos7             c8a648134623        8 weeks ago         196.6 MB
centos              latest              c8a648134623        8 weeks ago         196.6 MB
j_u14_as374_py276   latest              28f379d60882        10 weeks ago        871.5 MB
ubuntu              14.04               89d5d8e8bafb        10 weeks ago        187.9 MB

Currently I am using method suggested in save and load Docker images, but I believe there must be a better way to deal with all images.

If you want to export all images at once, create one big tar file:

docker save $(docker images -q) -o /path/to/save/mydockersimages.tar

If you want to save multiples images in one .tar file:

IDS=$(docker images | awk '{if ($1 ~ /^(debian|centos)/) print $3}')
docker save $IDS -o /path/to/save/somedockersimages.tar

Finally, if you want to export multiple many images, with one .tar file per images (not disk efficient: common layer are saved in each .tar file):

docker images | awk '{if ($1 ~ /^(openshift|centos)/) print $1 " " $2 " " $3 }' | tr -c "a-z A-Z0-9_.\n-" "%" | while read REPOSITORY TAG IMAGE_ID
do
  echo "== Saving $REPOSITORY $TAG $IMAGE_ID =="
  docker  save   -o /path/to/save/$REPOSITORY-$TAG-$IMAGE_ID.tar $IMAGE_ID
done

You may also want to save the list of images so that the restored images can be tagged:

docker images | sed '1d' | awk '{print $1 " " $2 " " $3}' > mydockersimages.list

On the remote machine, you can load (import) the images:

docker load -i /path/to/save/mydockersimages.tar

and tag the imported images:

while read REPOSITORY TAG IMAGE_ID
do
        echo "== Tagging $REPOSITORY $TAG $IMAGE_ID =="
        docker tag "$IMAGE_ID" "$REPOSITORY:$TAG"
done < mydockersimages.list

For more information about save/load, read: How to copy Docker images from one host to another without using a repository

docker save, Save one or more images to a tar archive (streamed to STDOUT by default) You can use gzip to save the image file and make the backup smaller. docker save  Reference: If you want to export all images at once, create one big tar file: docker save $(docker images -q) -o /path/to/save/mydockersimages.tar If you want to save

With windows server hosting the command is a little different. Using #EthanSN answer I found the following worked - using go formatting:

    docker save $(docker images --format '{{.Repository}}:{{.Tag}}') -o allinone.tar

And the load command:

    docker load -i allinone.tar

Worked perfectly with no need for the importing machine to download any images.

how to save all docker images and copy them to another computer, 1. to export: docker save $(docker images -q) -o dockerimages.tar 2. to import: /​how-to-save-all-docker-images-and-copy-to-another-machine. One way is to commit the image to a Private or Public Docker Repository and on the second host, run the “docker pull ” command. This will work most of the times, but if you dont have a private docker registry, you will have to look for other options. Docker has “save” feature which is used to persist an image.

Save all images with name:tag to one tar file:

docker save $(docker images | sed '1d' | awk '{print $1 ":" $2 }') -o allinone.tar

Then, load all images:

docker load -i allinone.tar

Where are Docker images stored on the host machine?, How do I copy a docker image to another machine? Copy image from machine to machine Unfortunately, for now it is not possible to do it with one command. Indeed, the machine scp command is used to copy the export image file between machines, so, before that, the docker machine ssh command is used to manage file on the source machine and at the end on the target machine.

Thanks a lot all your awnsers, but I find a basic and safe solution to save:

docker save -o ubuntu.tar myjenk:latest jenkins/jenkins:lts

REPOSITORY          TAG                    
myjenk              latest    
jenkins/jenkins     lts    

after to restore images:

docker load < ubuntu.tar

Export and Import a Docker Image Between Nodes – JamesCoyle , Commit your changes and save the container to an image called Copy the mynewimage.tar file to your new Docker instance using whatever method We have a problem when saving docker images and loading them on another machine  You can do this by saving the docker image as a tar file using the following command: docker save -o <path for generated tar file> <image_name>. After this, copy your image to another system (using cp or scp) Once this is done, load the image into docker using the following command: docker load -i <path to image tar file.

Using a registry, you can have a workflow similar to Git. Modify your container locally, commit changes to a local image, then push your image to the registry. You can then pull the image from your remote machine.

You can use the public Docker Hub, or you can set up your own registry server.

https://docs.docker.com/registry/

How to transfer docker images from one machine to another without , docker save -o <path for generated tar file> <image_name>. After this, copy your image to another system(using cp or scp) Once this is done,  docker commit NAME_OF_INSTANCE mycontainerimage. Now, save this image to a file and compress it. docker save mycontainerimage | gzip > mycontainerimage.tar.gz. Next, use your preferred file transfer method and copy mycontainerimage.tar.gz to the host where you want to migrate your container.

How to copy docker images from one host to another without a , 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  From the Docker host, use these three steps to copy a Docker container and place the container on another machine (server or host). Step #1: This command should work: docker save repositoryName:versionName > /tmp/destinationFileName.tar. Alternatively, you could try this command: docker save ImageName > /tmp/imagename.tar

How to Copy a Docker Image - Tutorial, Learn how to copy a docker image from one docker host system to another using the docker save and docker load commands. Can also be  This video explains how to copy images to other hosts. Commands used in this tutorial: docker run ubuntu /bin/bash -c "echo 'creating new image' /tmp/samplefile" docker commit container id

How to save all Docker images and copy to another machine, I have the below list of images present on my system and want to copy all these images to a remote machine. REPOSITORY TAG IMAGE ID CREATED VIRTUAL​ 

Comments
  • What is the problem with docker save/load ?
  • @Auzias in save/load method I will have to do it for 1 image at a time, looking for optimal way to deal with all images in one go.
  • That why bash is powerful. It can iterate and perform loops. See the answer of @kpie. And one command line is enough: docker save $(docker images -q)
  • @PavanGupta Did you find a better way to automate this process?
  • @AsmeJust not really, I needed it only once, however response from Franklin Piat looks promising.
  • I made the sinle huge tar and loaded it. got all images but none have repository or title/Tags. Now how the heck I'm suppose to know what images I have?
  • @Bsienn did it take so much time?
  • @suhayab no, On my system it took 20 or so mins.
  • Note that you may get hiccups using the "saving tags script" mentioned above, if you have images, which do not have any tags <none>. Perhaps an additional | grep -v '<none>' might do the trick here already.
  • I am looking to move a set of 6 containers created via docker-compose.yml to another computer. Will this method work? Will it also grab all volumes? Is that needed?
  • This answer if preferable for a couple of reasons. One: it doesn't use sed and awk to parse the output of docker commands, and instead produces the correct format from one command to the next. Two: it preserves the tags when you load, without the need to save them in a separate file and re-tag the images after loading.
  • easy and clean solution!
  • @rfay i don't think that's a better approach as you will lose all the titles and tags