Docker "Couldn't Find an Alternative Telinit Implementation to Spawn"

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  -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,

1 Answer

Could be a few things going on here depending on your versions. Have you tried Dan Walsh's older post?

In older versions this likely is because of two requirements Docker needs to do systemd:

  1. Need to run with --privileged
  2. 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

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

David Miller

David Miller

Executive Financial & Market Analyst

David Miller brings 15 years of experience in global economics, personal finance strategy, and market dynamics. He specializes in turning complex economic trends into actionable insights for everyday readers.

Share this article
Twitter Facebook Pinterest