Systemctl failed to get d-bus connection


I’m trying to install grafana using a doocker file and I keep getting errors when I try to install the service using systemctl

If I the following lines to the docker file
RUN /bin/systemctl daemon-reload
RUN /bin/systemctl enable grafana-server

then I get the following fatal error
Failed to get D-Bus connection: Unknown error -1

Is there any way to handle calls to systemctl inside the docker file?


Hey Chris,

You shouldn’t be starting starting daemons on the build server as there is no Systemd initiated yet. The init system is only started when the container hits the device. (RUN commands run on the build server and CMD runs on the device) So instead add these commands to a start script.

/bin/systemctl daemon-reload
/bin/systemctl enable grafana-server

Then call that script from the entry point.

CMD ["bash", "/"]

Let me know if this gets you on your way.


Actually, it looks like the problem here is just the daemon-reload part, which you shouldn’t need in your Dockerfile. Can you try just keeping the second command in your Dockerfile? i.e:

RUN systemctl enable grafana-server

We use this internally and works just fine.


Hi Craig and Petro,

Thanks for the suggestions. I tried Craigs solution and it works just fine. Will try removing daemon-reload and see how it goes.