docker "Couldn't find an alternative telinit implementation to spawn"
Could be a few things going on here depending on your versions. Have you tried Dan Walsh's older post? http://developers.redhat.com/blog/2014/05/05/running-systemd-within-docker-container/
In older versions this likely is because of two requirements Docker needs to do systemd:
- Need to run with --privileged
- Need to include volume /sys/fs/cgroup
If you strace, you may find:
ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
lstat("/run/systemd/system/", 0x7fffa5b4e300) = -1 ENOENT (No such file or directory)
execve("/lib/sysvinit/telinit", ["/usr/sbin/init"], [/* 8 vars */]) = -1 ENOENT (No such file or directory)
writev(2, [{"Couldn't find an alternative tel"..., 61}, {"\n", 1}], 2Couldn't find an alternative telinit implementation to spawn.
) = 62
exit_group(1) = ?
+++ exited with 1 +++
Note that somewhere along the line "init" and "telinit" became common symlinks which is frustrating. Even more confusing, this is a Red Hat-based distro (CentOS) whose legacy fallback should be Upstart, not SystemV. In any case, it's helpful to just call it what it is: use systemd binary directly, NOT /usr/sbin/init hoping it's a symlink to systemd binary.
In modern versions I've tried playing with symlinks to get things right but find the best way to go is actually just changing the run command a bit.
docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro [image] /bin/bash
Once you're that far it's perfectly alright to run systemd directly:
/usr/lib/systemd/systemd --system --unit=basic.target
This is how I see it with systemd version below:
Name : systemd
Arch : x86_64
Version : 219
Release : 19.el7_2.12
Size : 5.1 M
Hope this helps. Lots of older documents out there and changing systemd specs. JohnnyB
Mohamed Kamal
Updated on October 27, 2020Comments
-
Mohamed Kamal over 3 years
I'm a MAC user and installed docker inside a VM "ubuntu 14.04". (I installed everything manually, NOT using docker toolbox)
The problem is when I start specific container (other containers run normally), it gives me this weird error message "Couldn't find an alternative telinit implementation to spawn".
here is the Dockerfile I used to build the image:
FROM diegomarangoni/hhvm:cli # install php composer. # It needs git and the PHP zip extension # zlib1g-dev is needed to compile the PHP zip extension # openssh-client provides ssh-keyscan RUN apt-get update \ && apt-get install --assume-yes --no-install-recommends curl git zlib1g-dev openssh-client \ && apt-get clean && rm -r /var/lib/apt/lists/* \ && curl -sS https://getcomposer.org/installer -o installer \ && hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 installer \ && mv composer.phar /usr/local/bin/composer \ && rm installer WORKDIR /home/assert/scripts COPY scripts/composer.json /home/assert/ COPY scripts /home/assert/scripts RUN hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 -v Eval.Jit=false \ /usr/local/bin/composer install # Run the assert container web server CMD ["hhvm", "-v", "Eval.Jit=false", "/home/assert/scripts/vendor/bin/phpunit", "/home/assert/scripts/tests", "--configuration", "/home/assert/scripts/tests/phpunit.xml"] # keep it running CMD /sbin/init
and I start it using command:
docker run <CONTAINER>
Thanks in advance,
-
jaw over 6 yearsI used the Dockerfile mentioned in the blockpost (although with another CentOS 7 base image) and used the run command. However, when running
docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro [myimage] /bin/bash
, I getCannot find cgroup mount point: Operation not permitted Failed to allocate manager object: Operation not permitted
-
Niraj Nandane over 3 yearsI am also facing the issue on CentOS 7.8 systemd enabled image. Failed to get D-Bus connection: Operation not permitted
-
kmuenkel over 3 years@Niraj, this helped me with that issue: stackoverflow.com/questions/36617368/…