I’d like to create an image of an instance I’ve set up, and be able to spawn instances of that image on various other hosts, supplying different user-data to each.
At first we tried:
lxc export my-container backup.tar.gz # On another host lxc import backup.tar.gz my-new-container lxc stop my-new-container lxc config set my-new-container user.user-data=...
This does indeed create a matching container on the other host, however the user-data never runs (or at least, the runcmd within).
I suspect this is either because
cloud-init won’t run the runcmds again on an imported instance, or stopping and setting the config, and restarting the container won’t run those runcmds again.
Is there a workflow that can achieve what I need? I’ve done a bit of reading around and it looks like maybe I should rather be doing some combination of
lxc image export and
lxc image import. But I’m having trouble working out what the differences are between publish/export and also whether or not a published image will run a given