How to copy docker images from one node to another?

Say I have 10 docker images. In all 10 docker images, many layers are similar.

When using docker save -o saved image is self-contained and therefore the image size increases. (~ For a size of 10 images is about 9 GB)

After viewing the docker images, I examine:

 /var/lib/docker --- aufs (~3GB only) --- containers (Few KBs) --- image (Few KBs) --- ... --- mnt 

Is there a way to efficiently export images?

I also tried copy-paste aufs and the image folder to the new host. But some containers cannot start.

During log check:

/usr/bin/sudo must be owned by uid 0 and have the setuid bit set

Note. I already mentioned this one . This question is not duplicated. He did not allow my use case, which I mentioned above.

+5
source share
1 answer

I do not know if this is correct. But the below method worked for me. I tested with 30 Kolla Openstack Docker Images .

Why am I having a problem with docker save ?

As I said, I have 30 images of dockers. For now, I am saving with docker save -o <save image to path> <image name> . The total size is 15 GB, which is too large for a portable.

What I've done?

Long Story Short: I carefully copied the aufs and image folder.

Step 1:

In the machine you want to export: make sure that you have only images (which should be exported). Remove all containers that are started and stopped.

In the machine you want to import: make sure that you do not have images and containers.

Step 2: tar -cvf docker-images.tar /var/lib/docker/aufs /var/lib/docker/image It will close all 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 the docker. service docker restart .

+2
source

Source: https://habr.com/ru/post/1261300/


All Articles