Lxd publish documentation

I’m on a gentoo host.

Is there more complete documentation for the ‘lxc publish’ command? This is very sparse:

$ lxc publish --help
Publish containers as images

lxc publish [:][/] [:] [flags] [key=value…]

–alias New alias to define at target
–compression Define a compression algorithm: for image or none
-f, --force Stop the container if currently running
–public Make the image public

Global Flags:
–debug Show all debug messages
–force-local Force using the local unix socket
-h, --help Print help
-v, --verbose Show all information messages
–version Print version number

The only man page for lxc comes from lxc. There’s no lxc-publish man page and there’s no description of the publish function in the LXD docs, either.

For example, I’d like to know where ‘lxc publish’ publishes to, what it does, how it works, etc.

lxc publish turns a container or snapshot into an image in the local LXD image store.
So once it completes, it shows up in lxc image list and you can use it to create more containers, that’s about it.

1 Like

I suppose ssh host keys must be uniq for each container. Does it handled automatically or should I do something like

rm /etc/ssh/ssh_host_*
/usr/sbin/dpkg-reconfigure openssh-server

every time after I create new container from local published container?

It depends, if your container has cloud-init, this part may happen automatically for you when the new container boots up, but for any image which doesn’t have cloud-init configured to do it, you will want to wipe all those unique files before publishing.

Some of them (I seem to recall ssh being one of them) do get generated if missing on boot.

@stgraber First of all, thank you for this helpful answer.

That said, it’s just the sort of information that belongs in a man page or --help output for the function.

A function name like “publish” implies something public. There is the --public flag, I know, but it should be made clear that a straight publish sends the image to a safe place.

I know that documentation doesn’t get much love. Many of the responses to questions here in the forums would be useful additions to the docs/man pages/help pages. Perhaps I could assist here. What do I do?