>Currently, systemd in CentOS 7 has been removed and replaced with a fakesystemd package for dependency resolution. This is due to systemd requiring the CAP_SYS_ADMIN capability, as well as being able to read the host's cgroups. If you wish to replace the fakesystemd package and use systemd normally, please follow the steps below.
4 个回复
adolphlwq - https://blog.adolphlwq.xyz
赞同来自: styshoo 、silenceshell
首先恭喜你遇到了
centos:7
镜像的<strong>大坑</strong>!你的问题在(http://stackoverflow.com/quest ... -conne)
>Currently, systemd in CentOS 7 has been removed and replaced with a fakesystemd package for dependency resolution. This is due to systemd requiring the CAP_SYS_ADMIN capability, as well as being able to read the host's cgroups. If you wish to replace the fakesystemd package and use systemd normally, please follow the steps below.
上文是(https://github.com/docker-libr ... ration),大意是说
原来的systemd会需要CAP_SYS_ADMIN
,我们不想这样,就换成了<strong>fakesystemd</strong>,所以你会遇到上面奇葩的问题.当然官方repo也给出了(https://github.com/docker-libr ... -image)不过比较复杂.你可以使用
/usr/sbin/sshd &
来启动ssh服务.或者换成centos6
系列的镜像.总之centos7镜像太坑.这个问题我也遇到了.您可以参考下(https://github.com/sequenceiq/ ... erfile),这个是在centos6.5构建的镜像.
PS:这个问题困扰了我将近2天在弄明白.真是浪费时间.希望能帮助到您.
Persi
赞同来自: molifighting
<div class="aw-upload-img-list active">
<a href="http://dockone.io/uploads/answ ... ot%3B target="_blank" data-fancybox-group="thumb" rel="lightbox"><img src="http://dockone.io/uploads/answ ... ot%3B class="img-polaroid" title="centos7systemctlbug.png" alt="centos7systemctlbug.png" /></a>
</div>
centos7.2的镜像同样也有这个问题
bnuhero - 读书喝茶踢球写程序
赞同来自: CullenX
升级到最新的 CentOS 7.2 镜像能解决这个问题:(http://seven.centos.org/2015/1 ... ocker/)
yingz - 80后it男。。。
赞同来自:
将近两年前的问题了。
我最近也遇到这个问题。其实在docker hub的centos镜像的说明页面上有一节“Systemd integration”,已经介绍了如何在标准镜像的基础上启用systemd支持。按它给的Dockerfile再构建一个镜像即可,假设tag为centos:systemd。
启动的命令需要挂载cgroup的fs,并用init来做entrypoint。
<pre>
docker run -d -v /sys/fs/cgroup:/sys/fs/cgroup:ro --name centos centos:systemd /usr/sbin/init
</pre>
如果需要执行其它命令,可以执行exec进入容器
<pre>
docker exec -ti centos bash
</pre>