[lxc-devel] "Shutdown" LXC container

Christoph Mitasch cmitasch at thomas-krenn.com
Mon May 16 08:01:31 UTC 2011


Hi Tobi,

the idea is actually good, but my experience is that modern Linux
distros are unable to shutdown with "kill -s INT/PWR".

I tested on Debian Squeeze and Ubuntu Natty and it didn't work. What
distro are you using?

Check this thread:
http://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg01797.html

These are the ways to automatically shutdown a container cleanly I know
so far:
1) use a patched kernel to fix lxc-attach behaviour
https://launchpad.net/~serge-hallyn/+archive/lxc-natty/+packages
lxc-attach -n vm0 poweroff
2) use ssh daemon inside container to shutdown
3) create a small unix domain socket that runs inside the container.
Send special signal to the socket file from the host.

Regards,
Christoph

On 05/16/2011 01:16 AM, Tobias Gruetzmacher wrote:
> Hi,
> 
> it bugged me that there is no "clean" way to shut down a full system
> container from the outside, so I wrote the attached helper script.
> 
> It finds the "init" process for the container and sends the INT signal
> to that process, which most init systems (all?) interpret as a request
> to reboot the system. Changing the inittab (or whatever is cool with
> current init systems) to make the system halt instead gives us a nice
> way to shut down a container in a clean fashion.
> 
> Since this script may be usable for system shutdown scripts, I also
> implemented a timeout, but maybe lxc-wait should be extended to provide
> that functionality...
> 
> Thoughts, comments?
> 
> Greetings, Tobi
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Achieve unprecedented app performance and reliability
> What every C/C++ and Fortran developer should know.
> Learn how Intel has extended the reach of its next-generation tools
> to help boost performance applications - inlcuding clusters.
> http://p.sf.net/sfu/intel-dev2devmay
> 
> 
> 
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list