Restore last state working only for last container

I’ve just started playing around with lxd (host is Ubuntu 16.04, lxc packages are 2.0.8-0ubuntu1~16.04.2, with lxd 2.21-0ubuntu2~16.04.1 installed from xenial backports)

I was curious to see if containers start after host reboot. I’ve read about the boot.autostart config setting, documented as:

Always start the container when LXD starts (if not set, restore last state)

However, my observation is that if I have more than one container, and all are running, and all have the boot.autostart option unset, then only the last container (alphabetically) will be restarted after a host reboot. The others will not get started.

Is this something others have observed?

Thanks, and be gentle with a n00b :wink:
Andy

Actually, I checked and noticed that I get this as well. Only the last container was running. I started the other containers and it remembered them from there on. However, for a specific container, it would not start it even if it was previously running. I did not investigate deeper in order to produce a bug report.

By default, containers do not have a boot.autostart flag. LXD is supposed to remember whether they were running or stopped, and will start those that were running the next time it starts up again. How does LXD remember which containers were running? It should be in the lxd.db file (in /var/lib/lxd/lxd.db or /var/snap/lxd/current/lxd/lxd.db). A cursory look did not reveal something.

For me it definitely seems to always be the last. With two containers, deb-8 and u-16, renaming the Debian one to have zz at the start of its name was enough to make it the one that autostarts, instead of the Ubuntu one.

I’ll play about a bit more and then raise a bug, I think.

Cheers

When testing, you do not need to restart the computer, but rather just restart LXD.

If you use the DEB/PPA package, it’s

sudo systemctl lxd restart

If you use the snap package, it’s

sudo systemctl restart snap.lxd.daemon

Sounds the same as https://github.com/lxc/lxd/issues/4130
I hope to start looking into this issue very soon.