How to start D-Bus in Docker container

Many Linux applications require D-Bus which is not running by default in Docker containers.

When you attempt to start the application you might get the following error:

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

First of all you need to generate missing machine-id by command:

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

The application will be able to start even when the daemon is not running.

To start the D-Bus daemon inside the container you need to run following command on Ubuntu, Centos 7, Centos 8:

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

Command on Centos 6:

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

Now the daemon is running and your application should be able to start. The output should look like this:

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

11. June 2019 at 11:01 - Development (Tags: , , , , , ). Both comments and pings are currently closed.

Comments are closed.