I’ve been using images as a way of backup or to move a container to another server (including moving it to the same server after rebuilding it). So I do “lxc publish”, followed by “lxc image export”. Then I re-import with “lxc image import” and “lxc launch”. The image is used to launch a single container that recreates the container that the image was published from. I find images safer and more versatile than exported containers, for reasons explained here: https://github.com/lxc/lxd/issues/5172
But I realized recently (when I was looking at the disk space used by LXD) that such imported images contain container data that never goes away once the image is used to launch the container, because the container refers to that image, so the image stays in LXD for the life of the container (at least in the case of ZFS backend).
How can I get rid of this intermediate image? I’m thinking of creating a new container from the same original OS image, and then copy the restored container into the new one, using rsync directly on the underlying filesystems. Then delete the first container and the image it came from. But that’s contrived. I would like something like a one-off import of an exported image as a container, thus avoiding keeping the image in LXD.