8

如何在Docker容器中启动D-Bus

 3 years ago
source link: https://www.lujun9972.win/blog/2019/10/26/%E5%A6%82%E4%BD%95%E5%9C%A8docker%E5%AE%B9%E5%99%A8%E4%B8%AD%E5%90%AF%E5%8A%A8d-bus/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

如何在Docker容器中启动D-Bus

翻译自 https://georgik.rocks/how-to-start-d-bus-in-docker-container/

很多Linux应用需要用到 D-Bus, 但它在Docker容器中默认并不存在

当你尝试启动这类应用时,你会收到一个错误信息:

D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory
See the manual page for dbus-uuidgen to correct this issue.
  D-Bus not built with -rdynamic so unable to print a backtrace
Aborted

首先你需要通过下面命令生成缺失的 machine-id(译者注:我一般是直接在容器启动时挂载host上的machine-id):

dbus-uuidgen > /var/lib/dbus/machine-id

这样以来,即使DBus守护进程没有启动,应用也能启动

要在容器中启动D-Bus守护进程,你需要运行下面命令

mkdir -p /var/run/dbus
dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address

在 Centos 上则改为:

dbus-daemon --config-file=/etc/dbus-1/system.conf --print-address

现在守护进程运行起来了,你的应用也能用了. 输出的结果类似于下面这样:

unix:path=/var/run/dbus/system_bus_socket,guid=9cfabcc6f66027251e092e955d09e707

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK