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.
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 GBStep 3: In the machine, you want to import images,
tar -xvf docker-images.tar -C /var/lib/docker/
.Now restart docker.
service docker restart
.