Docker Centos7构建镜像无法使用service
原因:报这个错是因为dbus-daemon没能启动。systemctl并不是不能使用。将CMD或者entrypoint设置为/usr/sbin/init即可。docker容器会自动将dbus等服务启动起来
在Dockerfile
中启动服务则如下示例,示例启动http服务
RUN yum install -y httpd
&& systemctl enable httpd.service
CMD ['/usr/sbin/init']
还可以启动自定义的服务,和上面写的一样即可。
参考博文
雪饼
穆子航