[lxc-devel] Getting some hooks into the container configuration

Stéphane Graber stgraber at ubuntu.com
Thu May 24 21:19:27 UTC 2012


One of the common feature request I've heard about LXC, especially from
people who are used to OpenVZ is having a variety of hooks where they
can run their own script at various point of the container lifetime.

I had a quick look at what was available on OpenVZ and worked on a list
of hooks that I think would be useful to our users:

 - mount: Is run after the rootfs and any fstab entry for the container
have been mounted but before the container is started
 - start: Is run after the container init is started
 - stop: Is run after the container died
 - umount: Is run before the rootfs and any fstab entry for the
container are unmounted

At least the mount and umount ones can be quite useful to implement
features like the ephemeral containers where you want to stack an
overlayfs container or setup bind mounts based on a script output.

All of these scripts run outside of the container's namespaces.

The above list is meant to make it easy for anyone coming from OpenVZ to
convert their setup to LXC.

Potential other hooks include pre-start and post-stop, running even
before LXC mounts/umounts the rootfs but I'm not sure I'm seeing a use
case for these right know (where they wouldn't work as "mount" hooks).

These would be configurable in the container as:
lxc.hook.<HOOK> = <PATH>

Does that sound good to everyone? Are there other hooks we should make
sure we implement? Anything else I missed?

Thanks

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 900 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20120524/e5f88459/attachment.pgp>


More information about the lxc-devel mailing list