Let say I have 10 docker images. In all the 10 docker images many layers are similar.
While using docker save -o
, saved image is standalone and therefore images size grow bigger. (~ For 10 images size is around 9GB )
After pulled docker images, I explore:
/var/lib/docker
--- aufs (~3GB only)
--- containers (Few KBs)
--- image (Few KBs)
--- ...
--- mnt
Is there anyway to efficiently export images ?
I also tried copy-paste aufs and image folder to new host. But some containers can't start.
While inspect log:
/usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Note: I already referred this . This question is not duplicate of it. It didn't solve my use case which I mentioned above.
In order to transfer a Docker image from one server to another, what you need to do is first export the image to a file, then copy that file over from your current server to the new one using scp or rsync and finally load the image to your new server.
To push any local image to Container Registry using Docker or another third-party tool, you need to first tag it with the registry name and then push the image.
Yes! Let the docker save image command and the docker export image command do the trick! In this tutorial, you'll learn how to save and export containers and images for sharing by running Docker commands.
I don't know whether this is a correct approach. But Below method worked for me. I tested with 30 Kolla Openstack Docker Images.
Why I have problem with docker save
?
As I said, I have 30 docker images. While I save using docker save -o <save image to path> <image name>
. Total size is 15 GB which is too BIG to portable.
What I did ?
Long Story Short: I copied aufs and image folder carefully.
Step 1:
In the machine you want to export : Make sure you have only images(which are to be export). Remove all the containers which are running and stopped.
In the machine you want to import: Make sure You don't have any images and containers.
Step 2: tar -cvf docker-images.tar /var/lib/docker/aufs /var/lib/docker/image
It will zip all of your image layers and its database into a single tar file. Size is only 3 GB
Step 3: In the machine, you want to import images,
tar -xvf docker-images.tar -C /var/lib/docker/
.
Now restart docker. service docker restart
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With