Apply file to LXD

Hello,

I’m looking for a way to use LXD more declaratively –

Is there a way to directly create a container from a file? I’d like to be able to write a few files, and do something like lxd create|apply -f containers.yaml, kubectl style. Right now, I find myself manually editing files for containers and I was wondering if there was a more direct way to do so.

Thank you!

lxc init and lxc launch take config YAML from stdin.

See lxc launch --help:

 lxc launch ubuntu:20.04 u1 < config.yaml
      Create and start a container with configuration from config.yaml