Published image with lxc is too large

I have a question about publishing and exporting an lxd instance.

I have installed LXD on my Ubuntu 20.04.01 virtual machine. I need to create a container capable of running a Python application that uses torch and other libraries. Then, I would like to export this container as an image that I can deploy on other nodes.
I’ve chosen Ubuntu 20.10 from “images:” remote list on which I installed 200MB of torch. The downloaded image is of 102MB size but, after the launch, the installation of the library, and the publishing, the resulting image is of 550 MB. How is that possible since the original image is 102 MB and I installed only 200 MB?

P.S: I tried to launch the Ubuntu image and then publish it and the result is 136 MB, so even if I didn’t install anything, with lxc publish, the image is not 102 MB as before.

How can I achive better results in terms of sizing?

Thanks in advance :slight_smile:

Try running apt-get clean at least to remove duplicate package information.
Default publish also uses gzip whereas distributed images are often using xz, so you may want to change the algorithm during publish.

1 Like

It worked! Thank you @stgraber :slight_smile:

xz compression is better than the default one. The image size dropped from 550 MB to 380 MB