我是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
我用命令启动它:
docker run
提前致谢,
根据您的版本,这里可能会有一些事情发生.你有没有试过Dan Walsh的老帖子? http://developers.redhat.com/blog/2014/05/05/running-systemd-within-docker-container/
在旧版本中,这可能是因为Docker需要做systemd的两个要求:
>需要与–privileged一起运行
>需要包含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 +++
请注意,沿着“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
一旦你到目前为止,直接运行systemd是完全正常的:
/usr/lib/systemd/systemd --system --unit=basic.target
这是我用systemd版本看到它的方式:
Name : systemd
Arch : x86_64
Version : 219
Release : 19.el7_2.12
Size : 5.1 M
希望这可以帮助.很多旧文档和更改系统规格.
JohnnyB