Modify LXC STOP behavior per container

I see that lxc stop by default waits 60 secs for a clean exit then force shutdown the CT.

is it possible to modify the shutdown behavior per CT w/o resorting to flags when issuing a shutdown (or when the host is rebooting)? some CTs run systemd services which take longer to exit, and/or must exit cleanly otherwise data is corrupted. How can set some CTs to always wait 180 seconds before a force shutdown?

I think that’s controllable with boot.host_shutdown_timeout, see https://linuxcontainers.org/lxd/docs/master/reference/instance_options/#boot-related-options.

If you always want that to be different from the default, you can put it in the default profile.

2 Likes

Worth saying that lxc-stop you linked to is from lxc and not lxd project. Whilst what @sdeziel linked to is for lxd. Also worth saying that lxc stop won’t forcefully stop an instance when the timeout is reached.

1 Like

God catch Thomas, thank you. There is also a dash there, making it visibly different.

What is the default timeout period for lxc stop and where can I find the flags available for it besides -f? All I see is a description of its effect.

There is no time out by default.

You can add --help to all lxc commands to see the options available.

The config option @sdeziel linked to is used by lxd during shutdown or evacuation when it needs to ensure all instances are stopped somehow.

1 Like