本文参考自:https://blog.youkuaiyun.com/shenzhen_zsw/article/details/73928195
在centos7的docker容器里面不能用service启动服务。
service *** start
报错内容:Failed to get D-Bus connection: Operation not permitted。
可能的解决方案为:docker run容器的时候加上 --privileged 参数,以及在最后加上“ /usr/sbin/init”。
报这个错的原因是dbus-daemon没能启动。systemctl并不是不能使用。将CMD或者entrypoint设置为/usr/sbin/init即可。docker容器会自动将dbus等服务启动起来。如下:
docker run --privileged -itd --name centos docker.io/centos:7 /usr/sbin/init