Hello,
No replies so far from the devuan-dev list. Maybe with a larger audience I can
get some help!
Thanks!
Hello,
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
fi
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
fi
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:
https://stackoverflow.com/questions/20010199/how-to-determine-if-a-process-runs-inside-lxc-docker
https://stackoverflow.com/questions/23513045/how-to-check-if-a-process-is-running-inside-docker-container
https://en.wikipedia.org/wiki/Docker_(software)
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
1:name=elogind:/1
0::/
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.
Thanks!