Commit 27234deb by Jonathan Calmels

hooks: add dhclient hooks

Add new hooks leveraging dhclient from the host to automatically configure the container interfaces. This is especially useful for application containers which rely on an IPAM driver for network configuration (e.g. Docker). Signed-off-by: 's avatarJonathan Calmels <jcalmels@nvidia.com>
parent f6fc1565
......@@ -136,6 +136,8 @@ doc/manpage.refs
doc/api/html/*
hooks/unmount-namespace
hooks/dhclient-start
hooks/dhclient-stop
m4/
......
......@@ -889,6 +889,8 @@ AC_CONFIG_FILES([
doc/ko/see_also.sgml
hooks/Makefile
hooks/dhclient-start
hooks/dhclient-stop
templates/Makefile
templates/lxc-alpine
......
......@@ -5,6 +5,9 @@ hooks_SCRIPTS = \
clonehostname \
mountecryptfsroot \
ubuntu-cloud-prep \
dhclient-script \
dhclient-start \
dhclient-stop \
squid-deb-proxy-client
binhooks_PROGRAMS = \
......
#! /bin/bash
set -e
LXC_HOOK_DIR="@LXCHOOKDIR@"
rootfs="${LXC_ROOTFS_PATH##*:}"
pidfile="${rootfs%/*}/dhclient.pid"
mkdir -p "${rootfs}/var/lib/dhclient"
nsenter -u -U -n -t "${LXC_PID}" -- \
/sbin/dhclient -nw -1 -pf ${pidfile} -lf ${rootfs}/var/lib/dhclient/dhclient.leases -e ROOTFS=${rootfs} -sf ${LXC_HOOK_DIR}/dhclient-script
#! /bin/bash
set -e
LXC_HOOK_DIR="@LXCHOOKDIR@"
rootfs="${LXC_ROOTFS_PATH##*:}"
pidfile="${rootfs%/*}/dhclient.pid"
# XXX Stop hook namespace arguments are wrong for some reason, those are the host namespaces not the container ones.
# Retrieve the namespaces from the dhclient pidfile instead.
nsenter -u -U -n -t $(< ${pidfile}) -- \
/sbin/dhclient -r -pf ${pidfile} -lf ${rootfs}/var/lib/dhclient/dhclient.leases -e ROOTFS=${rootfs} -sf ${LXC_HOOK_DIR}/dhclient-script
rm -f ${pidfile}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment