The 'dind' script assumes that the dockerd process will start with pid 1.
This is often not the case when building from the dind image and this causes an error "sed: write error" on systems that use cgroup v2.
Could I suggest checking the process ID of dockerd rather than assuming it is 1 in the dind script? Something like:
# cgroup v2: enable nesting
if [ -f /sys/fs/cgroup/cgroup.controllers ]; then
# move the init process (PID 1) from the root group to the /init group,
# otherwise writing subtree_control fails with EBUSY.
mkdir -p /sys/fs/cgroup/init
DOCKERDPID=$(/usr/bin/pgrep dockerd | wc -l)
echo $DOCKERDPID > /sys/fs/cgroup/init/cgroup.procs
# enable controllers
sed -e 's/ / +/g' -e 's/^/+/' < /sys/fs/cgroup/cgroup.controllers > /sys/fs/cgroup/cgroup.subtree_control
fi
The 'dind' script assumes that the dockerd process will start with pid 1.
This is often not the case when building from the dind image and this causes an error "sed: write error" on systems that use cgroup v2.
Could I suggest checking the process ID of dockerd rather than assuming it is 1 in the dind script? Something like: