容器中的centos7解决failed to get d-bus connection operation not permitted
在容器中安装了centos7,但是在运行systemctl
命令时,会报错:
1Failed to get D-Bus connection: Operation not permitted
在网上找了很多资料,基本上都是在没有实测试的情况下说的,有说在创建容器时添加--privileged=true
参数的,也有说需要添加/usr/sbin/init
以执行相应的命令来启动systemd
的,还有说两个参数都需要添加的。这些方法都试了一遍,也没解决到问题,同样会报相同的错误。
终于在 https://blog.hlhasd.com/archives/resource-sharing/tool/28/864/查找到了解决方案:
1mv /usr/bin/systemctl /usr/bin/systemctl.old
2curl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py > /usr/bin/systemctl
3chmod +x /usr/bin/systemctl
实测试有效。
如果有对你有帮助,欢迎点赞收藏!
- 原文作者:Witton
- 原文链接:https://wittonbell.github.io/posts/2024/2024-09-19-容器中的centos7解决failed-to-get-d-bus-connection-operation-not-permitted/
- 版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议. 进行许可,非商业转载请注明出处(作者,原文链接),商业转载请联系作者获得授权。