Skip to content

Commit 255b6aa

Browse files
committed
Work around an exotic bug affecting Docker-in-Docker + systemd.
1 parent 83a2e92 commit 255b6aa

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

hack/dind

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,31 @@ do
2727
[ -d $CGROUP/$SUBSYS ] || mkdir $CGROUP/$SUBSYS
2828
mountpoint -q $CGROUP/$SUBSYS ||
2929
mount -n -t cgroup -o $SUBSYS cgroup $CGROUP/$SUBSYS
30+
31+
# The two following sections address a bug which manifests itself
32+
# by a cryptic "lxc-start: no ns_cgroup option specified" when
33+
# trying to start containers withina container.
34+
# The bug seems to appear when the cgroup hierarchies are not
35+
# mounted on the exact same directories in the host, and in the
36+
# container.
37+
38+
# Named, control-less cgroups are mounted with "-o name=foo"
39+
# (and appear as such under /proc/<pid>/cgroup) but are usually
40+
# mounted on a directory named "foo" (without the "name=" prefix).
41+
# Systemd and OpenRC (and possibly others) both create such a
42+
# cgroup. To avoid the aforementioned bug, we symlink "foo" to
43+
# "name=foo". This shouldn't have any adverse effect.
44+
echo $SUBSYS | grep -q ^name= && {
45+
NAME=$(echo $SUBSYS | sed s/^name=//)
46+
ln -s $SUBSYS $CGROUP/$NAME
47+
}
48+
49+
# Likewise, on at least one system, it has been reported that
50+
# systemd would mount the CPU and CPU accounting controllers
51+
# (respectively "cpu" and "cpuacct") with "-o cpuacct,cpu"
52+
# but on a directory called "cpu,cpuacct" (note the inversion
53+
# in the order of the groups). This tries to work around it.
54+
[ $SUBSYS = cpuacct,cpu ] && ln -s $SUBSYS $CGROUP/cpu,cpuacct
3055
done
3156

3257
# Note: as I write those lines, the LXC userland tools cannot setup

0 commit comments

Comments
 (0)