Failed to get D-Bus connection: Operation not permitted


centos7.4 在docker容器中使用systemctl報錯

報錯:

[root@be474fdeb4d1 /]# systemctl start php

Failed to get D-Bus connection: Operation not permitted

原因:在centos7的docker容器里面不能用service啟動服務。

報這個錯的原因是dbus-daemon沒能啟動。systemctl並不是不能使用。將CMD或者entrypoint設置為/usr/sbin/init即可。docker容器會自動將dbus等服務啟動起來。

解決方法:

docker run --privileged -it --name web centos:7.4.1708 /usr/sbin/init #運行容器

docker exec -it web /bin/bash #進入容器

[root@0ff32a826787 /]# systemctl start php-fpm

[root@0ff32a826787 /]# systemctl enable php-fpm

Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM