Store information in published container?


Is there a way to store information when a container are published ?
I look around lxc config but the namespace user.* are not kept, even description field is ephemeral.

I would like to store the list of profiles used with the container.

Thanks for your help ;o)

lxc config metadata edit will let you set properties that will be part of the image when published.

1 Like

less useful than lxc config set/get but it does the job !

Thanks a lot ;o)

I have not found an existing solution to have a “trigger” around the publication such as pre-publish or post-restore.
A solution is to implement a parent script (bash for example) to launch lxc publish/init

Another elegant way is to have an option to call a script before publishing from lxc publish and after lxc init.

Is there an existing solution?

I take this opportunity to ask you if there a way to modify by script the container metadata ?

I know I can use use lxc config metadata edit manually but is not usable for a script.
With BTRFS filesystem I can modify the yaml file directly but with ZFS I have to mount/umount container filesystem and I get issues.
I look around lxc config get/set without success.

Is there a undocumented way to do this ? Thank you

LXC offers a good remote API to copy containers between hosts, but I would like to backup/restore containers with images and so keep associated profiles.

May be I’m in a wrong way to manage configured containers with images ?

All of our edit commands support reading from stdin. So you can do echo SOME-YAML | lxc config metadata edit from a script.

1 Like

really fine !
thank you