9

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.

Community
  • 1
  • 1
rajagopalx
  • 3,012
  • 9
  • 41
  • 52
  • 1
    Possible duplicate of [How to copy docker images from one host to another without via repository?](http://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-via-repository) – BMitch Dec 15 '16 at 00:32
  • The best solution is to run a registry server, your own private server can be spun up in a container, TLS encrypted sessions, and password protected if security is a concern. – BMitch Dec 15 '16 at 00:34
  • 1
    Of course, I can run registry server. But I want to carry my docker images in portable media like USB or CD. – rajagopalx Dec 15 '16 at 00:47
  • Does this answer your question? [How to save all Docker images and copy to another machine](https://stackoverflow.com/questions/35575674/how-to-save-all-docker-images-and-copy-to-another-machine) – Mišo Sep 02 '20 at 08:00

1 Answers1

4

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.

rajagopalx
  • 3,012
  • 9
  • 41
  • 52