Delete all images

Hi all!

We are running Ubuntu 16.04 server with lot of services inside LXD. We are taking images from containers as backups and moving to ecternal server. We want to have /var/lib/lxd/images clean. I guess is ok to erase all images there, right? even .rootfs?

Thanks in advance!

Is your “lxc image list” output empty?

If so, then yes, you can go remove anything that’s leftover in /var/lib/lxd/images.
If not, then no. LXD does need to have the image files around for any image it keeps track of. Otherwise it won’t be able to convert it to new formats or to export it.

Ok then all images are in /var/lib/lxd/images the first launch containers ones and the ones created by lxc publish container_name --alias image_name but all them are mixed and even with the alias I’ve got ID.tar.gz that as I understood is imperative that fingerprint.

But our /var/lib/lxd/images is rapidly increasing size, which is the way to erase only images create by lxc publish container_name or a way to create those images on a different directory?

Or is there a way you can name images instead of ID? And then we can append date to them? like on this article you wrote appeared but couldn’t find the way:

stgraber@dakara:~$ lxc image export old-ubuntu .
Output is in .
stgraber@dakara:~$ ls -lh *.tar.xz
-rw------- 1 stgraber domain admins 656 Mar 30 00:55 meta-ubuntu-12.04-server-cloudimg-amd64-lxd.tar.xz
-rw------- 1 stgraber domain admins 156M Mar 30 00:55 ubuntu-12.04-server-cloudimg-amd64-lxd.tar.xz

Thanks!

/var/lib/lxd/images is internally managed by LXD. As you remove images from the image store with “lxc image delete”, LXD will clean entries in /var/lib/lxd/images for you.

If you go behind LXD’s back and clean things from /var/lib/lxd/images directly, you will break LXD.

Every time you run “lxc publish”, an image is generated, which means a new tarball shows up in /var/lib/lxd/images.
Once you remove that image from the image store with “lxc image delete”, the tarball will go away from /var/lib/lxd/images.

1 Like

Thanks for clarification @stgraber, one more question, we launch some containers at X date and then “lxc publish” after this date. Then is safe to do “lxc image delete” for the ID’s after the launching date?

Also, is it possible to edit ID after “lxc publish” by “lxc image edit” to show alias or date instead of ID?