Why does this matter? Well, sometimes I want to copy a container and replace some rather chunky blocks of config, in particular cloud-init.network-config and cloud-init.user-data. I have a neat way of passing these overrides to incus launch, but not to incus copy.
There’s incus config edit, but unfortunately it requires the full set of keys (including volatile ones) to be passed:
incus config edit test2f <<EOS
config:
user.greeting: bonjour
EOS
# => Error: Volatile idmap keys can't be deleted by the user
So I guess incus copy accepting input on stdin wouldn’t be all that useful, unless there were a “merge” mode for config updates (which wouldn’t give you a way to unset a value)
I’m not sure if this is relevant to your copy-based workflow, but my approach to those chunky blocks of cloud-init config is to put them in files and add them with incus config set to not-yet-started instances.
# create a container with a profile…
incus create images:alpine/3.22/cloud test123 --profile testprofile
# …or an ad-hoc config
incus create images:alpine/3.22/cloud --no-profiles test123 < config.yml
# add cloud-init config from a file…
incus config set test123 cloud-init.vendor-data - < init.yml
# …or perhaps a heredoc
incus config set test123 cloud-init.vendor-data - <<EOS
#cloud-config
user: testuser
timezone: Africa/Casablanca
EOS
# then start the container and wait for cloud-init
incus start test123 && incus exec test123 -- cloud-init status --wait
Maybe doing some similar incus config sets after the copy does what you want?
What I wanted was something vaguely atomic: if the copy was made, then it definitely has a different config to the original. But on balance, your version is clearer.
It is slightly concerning that neither the documentation nor the built-in help for incus config set says that you can pass a value on stdin, if the placeholder value is “-”. (And presumably, nobody ever wants to set a configuration value to the literal value “-”?)
I think that I can safely guess that this feature was simply not picked during the last iteration of documentation writing. And can be added with a PR (easy task) if someone wants to pick up. I think the first step is to file an issue on Github, then let someone pick it up.
Not in this case: the config I want to apply is specific to the container in question, in particular the static IP address in cloud-init.network-config. Making a separate profile for each container doesn’t make sense.