Centos7 docker容器报 docker Failed to get D-Bus connection 错误(新增Ubuntu的类似问题解决方案)

在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

 

需要注意的是,docker 容器运行Ubuntu遇到类似的问题时:

System has not been booted with systemd as init system (PID 1). Can't operate.

/usr/sbin与/sbin并不是链接关系,在/usr/sbin下没有init的

docker run --privileged -ti --name test1  ubuntu /sbin/init

转载自:https://blog.csdn.net/shenzhen_zsw/article/details/73928195

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章