[Lxc-users] Best way to shutdown a container

Clemens Perz cperz at gmx.net
Fri Aug 13 14:30:23 UTC 2010


On 08/13/2010 03:55 PM, Clemens Perz wrote:
> Hi!
> 
> I used to run lxc-stop on my system containers when I actually want to
> run a halt. Only today I noticed, that stop actually kills all
> processes, not really doing a halt. I went through the lxc commands and
> did not find something graceful to do this job from the host systems
> shutdown scripts.
> 
> Did I miss it? Maybe lxc-halt is a missing piece ;-) Is there a simple
> way to do it, preventing the need to login to the container and run halt?
> 

I read the stuff on the list about powerfail, creating deamons and
stuff. Seems that it might not be generic enough. What about this:

lxc-start opens @/var/lib/container/command and keeps it open until the
container dies. As far as I know, lxc-info already communicates over
this socket. So, could we send a message to the init process of the
container, just like telinit does?

strace telinit 2 on my system shows this bit:

open("/dev/initctl", O_WRONLY)          = 3
write(3,
"i\31\t\3\1\0\0\0002\0\0\0\5\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 384)
= 384

So at the end, its just writing some information into the initctrl
device of the container. Hmm, dunno if this works for upstart.

Sorry for telling any rubbish here - just thinking ;-))

Cheers,
Clemens






More information about the lxc-users mailing list