systemctl failed to connect to bus - docker ubuntu:16.04 container

I assume you start your docker container with something like

docker run -t -i ubuntu:16.04 /bin/bash

The problem now is that your init process PID 1 is /bin/bash, not systemd. Confirm with ps aux.

In addition to that you are missing dbus with would be the way to communicate. This is where your error message is coming from. But as your PID 1 is not systemd, it will not help to install dbus.

Best would be to re-think the way you plan to use docker. Do not rely on systemd as a process manager but have the docker container run your desired application in the foreground.


Others have reported a similar problem. Start up the terminal and type:

$ env

Do you see an environment variable like this?

XDG_RUNTIME_DIR=/run/user/`id -u`

Where id -u is enclosed in backticks not single quotes. This variable is reinterpreted into a number usually 1000 for regular users and 0 for super user (sudo).

If the environment variable XDG_RUNTIME_DIR does not exist you need to create it. The full discussion is in launchpad systemd answers.


Just start the dbus service:

/etc/init.d/dbus start