:: [DNG] Help needed:[Fwd: eudev: Meth…
Top Page
Delete this message
Reply to this message
Author: Svante Signell
To: Devuan dng ml
Subject: [DNG] Help needed:[Fwd: eudev: Methods to detect if running in a container.]

No replies so far from the devuan-dev list. Maybe with a larger audience I can
get some help!


I'm trying to solve the problem of detecting if you are within a container, like
docker or LXC when running the eudev init script. If true udevd should not be
cstarted. The current version of eudev (3.2.9-4) has a buggy check for
containers, and people running runit as init have problems, see #392.

eudev-3.2.7-6 has the following test:
if ! ps --no-headers --format args ax | egrep -q '^\['; then
log_warning_msg "udev does not support containers, not started"
exit 0
I don't know the origin of this test and have not found anything about the
output within a container.

udev-244-3 has the following test:
if [ ! -w /sys ]; then
log_warning_msg "udev does not support containers, not started"
exit 0
This test is buggy since /sys is a directory not a file and /sys is always
writable when running. Any command triggers this test:
/etc/init.d/udev status
udev does not support containers, not started ... (warning).

Googling around the following tests shows:

1) cat /proc/1/sched | head -n 1
# Container: bash (5276, #threads: 1)
# No container: init (1, #threads: 1)

2) grep 'docker\|lxc' /proc/1/cgroup
Note 1: On a beowulf image it is empty??
Note 2: On a systemd-free Debian/bullseye image it shows
Note 3: On a systemd-free Debian/buster image:
<same as above> after removing systemd-shim and cgmanager

3) cat /proc/1/environ | tr '\0' '\n' | grep ^container

Any help on this subject is appreciated, especially the output of the above
tests when running in a container.