在centos7的docker容器里面不能用service启动服务。
systemctl start sshd
报错内容:Failed to get D-Bus connection: Operation not permitted。
报这个错的原因是dbus-daemon没能启动。systemctl并不是不能使用。将CMD或者entrypoint设置为/usr/sbin/init即可。docker容器会自动将dbus等服务启动起来。如下:
docker run --privileged -ti --name test1 centos /usr/sbin/init
转载自:https://blog.csdn.net/shenzhen_zsw/article/details/73928195