What happens when container is stopped?

I am wondering what exactly happens when you stop a container (either by lxc stop or shutting down the host).

I mean will a service (like i.e. postgres) running in the container be shut down gracefully or is it more like pulling the power cable?

lxc stop sends a signal to the init system in the container so it can perform a clean shutdown.

lxc stop --force will instead kill (SIGKILL) all processes in the container.

Both are cleaner than pulling the power cable as the kernel is still running and will still cleanly flush writes to the filesystem, but --force would still cause some potential damage as any data which is still kept in memory would not be flushed.

thx

… shutting down the host = lxc stop, crashing of the host = lxc stop --force?

Yes basically