Can't shutdown LXC container

timonoj

Active Member
Apr 19, 2017
20
0
41
44
Hi guys!

I have every few days a persistent container that refuses to let itself shut. It times out on any shutdown attempt, and so far the only solution I found is to reboot the whole server because of a single container. Is there a way to force shutdown an LXC container?

This is what I get:
Code:
command 'lxc-stop -n 108 --nokill --timeout 60' failed: exit code 1

root@server:/usr/bin# pct exec 108 poweroff
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "en_GB.UTF-8",
LANG = "C.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("C.UTF-8").
root@server:/usr/bin# pct exec 108 stop
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_TIME = "en_GB.UTF-8",
LANG = "C.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("C.UTF-8").
lxc-attach: 108: attach.c: lxc_attach_run_command: 1450 No such file or directory - Failed to exec "stop"
What else can I do to force the container to die?

EDIT: When this happens, I can't even reboot the server normally, I need to do a hard reboot by holding the power button. It's really nasty and I'd like to find any better way to do this.
 
hi,

you can force shutdown the unresponsive container if you kill the respective lxc process, ps aux | grep CTID will give you a list of processes, you can kill the respective /usr/bin/lxc-start process to kill the container.

however this shouldn't be necessary most of the time. it's a better idea to figure out why the container won't shutdown normally.

the command you used:
Code:
root@server:/usr/bin# pct exec 108 stop
is not what you're looking for. pct exec is for running a command inside the container. you can try with pct stop CTID instead.

a common reason for containers not shutting down can be mounted filesystems (especially network filesystems) or other hanging services.
 
Thanks for your prompt reply. I'm willing to bet that pct stop will have the same effect, but I'll have to wait until it crashes again...I might report later this week :)
There is indeed a network filesystem mounted, but there was no network interruption whatsoever, and the same mounts have been unaffected in many other container. It's just this one that crashes...
 
Last edited:
There is indeed a network filesystem mounted, but there was no network interruption whatsoever, and the same mounts have been unaffected in many other container. It's just this one that crashes...
you have to unmount the network storage before stopping the container - otherwise systemd will wait for it during shutdown