docker"无法找到替代的telinit实现来生成"

Moh*_*mal 8 hhvm docker ubuntu-14.04 docker-compose

我是一个MAC用户,并在VM"ubuntu 14.04"中安装了docker.(我手动安装了一切,使用docker工具箱)

问题是当我启动特定容器(其他容器正常运行)时,它给了我这个奇怪的错误消息" 无法找到替代的telinit实现来生成 ".

这是我用来构建映像的Dockerfile:

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
Run Code Online (Sandbox Code Playgroud)

我用命令启动它:

docker run <CONTAINER>
Run Code Online (Sandbox Code Playgroud)

提前致谢,

Boe*_*Boy 9

根据您的版本,可能会发生一些事情.你有没有试过Dan Walsh的老帖子?http://developers.redhat.com/blog/2014/05/05/running-systemd-within-docker-container/

在旧版本中,这可能是因为Docker需要做systemd的两个要求:

  1. 需要与--privileged一起运行
  2. 需要包含volume/sys/fs/cgroup

如果你strace,你可能会发现:

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 +++
Run Code Online (Sandbox Code Playgroud)

请注意,沿着"init"和"telinit"这一行的某个地方变成了常见的符号链接,令人沮丧.更令人困惑的是,这是一个基于Red Hat的发行版(CentOS),它的遗留回退应该是Upstart,而不是SystemV.在任何情况下,只是调用它是有帮助的:直接使用systemd binary,NOT/usr/sbin/init希望它是systemd二进制文件的符号链接.

在现代版本中,我尝试使用符号链接来解决问题,但找到最佳方法实际上只是稍微更改了运行命令.

docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro [image] /bin/bash
Run Code Online (Sandbox Code Playgroud)

一旦你到目前为止,直接运行systemd是完全正常的:

/usr/lib/systemd/systemd --system --unit=basic.target
Run Code Online (Sandbox Code Playgroud)

这是我在下面的systemd版本中看到它的方式:

Name        : systemd
Arch        : x86_64
Version     : 219
Release     : 19.el7_2.12
Size        : 5.1 M
Run Code Online (Sandbox Code Playgroud)

希望这可以帮助.很多旧文件和更改系统规格.JohnnyB