本文介绍了在docker容器中启动服务失败,错误:无法获取D-Bus连接:无连接到服务管理器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当我ssh到容器并运行命令 service xxx start ,弹出一个错误:

实际上, fakesystemd 安装在容器中,而不是 systemd



所以我删除了 fakesystemd 并使用命令安装 systemd
yum swap - 删除fakesystemd - 安装systemd systemd-libs



但是我仍然无法启动服务:

D任何人都会遇到并解决这个问题?

解决方案

这是与Docker容器内的 systemd 操作系统。



简短答案:以 systemd 替换 fakesystemd ,您需要附加 / sys / fs / cgroup 作为容器中的只读卷,构建映像,然后以特权模式运行。



这是。它使用Centos作为示例,但应该适用于任何 systemd 的操作系统。


I installed docker image and built a image successfully.

When I ssh to the container and run the command service xxx start, an error popped:

Actually, fakesystemd is installed in the container instead of systemd.

So I removed fakesystemd and installed systemd with the command: yum swap -- remove fakesystemd -- install systemd systemd-libs

But I still can't start the service:

Does anyone ever meet and solved this issue?

解决方案

This is known issue with systemd-based OSes inside Docker containers.

Short answer: as well as replacing fakesystemd with systemd you need to attach /sys/fs/cgroup as a read-only volume into the container, build the image and then run it in "privileged" mode.

This is the best guide I've found for this. It uses Centos as the example, but should work with any systemd-based OS.

这篇关于在docker容器中启动服务失败,错误:无法获取D-Bus连接:无连接到服务管理器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 12:34