Failed to get D-Bus connection: Operation not permitted

在docker中启用systemd时,过程中出现:
Failed to get D-Bus connection: Operation not permitted

原因

systemd维护系统服务程序,它需要特权去会访问Linux内核。而容器并不是一个完整的操作系统,只有一个文件系统,而且默认启动只是普通用户这样的权限访问Linux内核,也就是没有特权,所以自然就用不了!

解决

添加授权:
docker run -d -name centos7 --privileged=true centos:7 /usr/sbin/init

增加授权会提高风险,需要仔细评估具体的运行脚本和命令,避免对宿主造成安全风险

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注