I’m following these directions to create an LXC box on Debian 7 (wheezy):
I start a container/guest using this command:
sudo lxc-start -n wheezy-base
But when I halt it, the host stops as well.
What am I doing wrong? How to stop an LXC guest correctly and get back to the host?
You’re using Debian 7, and don’t have access to LXC user namespaces (which should be available in jessie, and are available in stretch). So, “root” in a container is equivalent to root on the host. Thus when you call
sudo halt you are doing so as root for the whole system.
(Containers on such older systems are not secure and cannot be made secure; you should be using a newer version of Debian, or preferably a Red Hat-based system, for any container work that requires even a moderate amount of security.)
To kill a container, from outside the container use
lxc-stop -n wheezy-base -k`
From inside the container, try
kill -PWR 1 to fake the container’s init process into thinking the (nonexistent) power button has been pressed.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.