Creating container from rootfs tgz

What’s the best way to create an lxd container from an arbitrary rootfs tgz file?

My colleagues are working with Yocto Linux and generating root filesystems in tgz format. I’ve been able to import these files directly into Docker and WSL. But I still haven’t worked out how to do the equivalent in LXD.

I suspect the best way today is to use distrobuilder --pack-lxd, but I haven’t been able to find any usage examples. Do I need to create the .yaml file? Can someone provide a real example?


When using distrobuilder to build custom images I usually borrow the .yaml from the LXD CI repository.
An example for Ubuntu: but you have a couple others in there as well.

Thanks. It seems that using distrobuilder would be more complicated than I had hoped: there’s lots to understand in the yaml files. But I stumbled on this alternative approach:

This works for me (so far!)

1 Like

You can also then export that as an image using lxc publish.