Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run dbus-daemon inside Docker container

I am trying to create a Docker container with a custom D-Bus bus running inside.

I configured my Dockerfile as follow:

FROM ubuntu:16.04
COPY myCustomDbus.conf /etc/dbus-1/
RUN apt-get update && apt-get install -y dbus
RUN dbus-daemon --config-file=/etc/dbus-1/myCustomDbus.conf

After building, the socket is created but it is flagged as "file", not as "socket", and I can not use it as a bus...

-rwxrwxrwx  1 root root    0 Mar 20 07:25 myCustomDbus.sock

If I remove this file and run the dbus-daemon command again in a terminal, the socket is successfully created :

srwxrwxrwx  1 root root    0 Mar 20 07:35 myCustomDbus.sock

I am not sure if it is a D-Bus problem or a docker one.

like image 954
oOnez Avatar asked Mar 20 '17 07:03

oOnez


People also ask

How do I start Docker daemon inside a container?

To run docker inside docker, all you have to do it just run docker with the default Unix socket docker. sock as a volume. Just a word of caution: If your container gets access to docker. sock , it means it has more privileges over your docker daemon.

Can I use GPU in Docker?

The Docker engine doesn't natively support NVIDIA GPUs as it uses specialized hardware that requires the NVIDIA driver to be installed. This is our experience of using a graphics processing unit to build and run Docker containers and a step-by-step description of how this was achieved.

What is D-Bus daemon?

D-Bus is first a library that provides one-to-one communication between any two applications; dbus-daemon is an application that uses this library to implement a message bus daemon. Multiple programs connect to the message bus daemon and can exchange messages with one another.


2 Answers

Instead of using the "RUN" command, you should use the "ENTRYPOINT" one to run a startup script.

The Dockerfile should look like that :

FROM ubuntu:14.04
COPY myCustomDbus.conf /etc/dbus-1/
COPY run.sh /etc/init/
RUN apt-get update && apt-get install -y dbus
ENTRYPOINT ["/etc/init/run.sh"]

And run.sh :

#!/bin/bash
dbus-daemon --config-file=/etc/dbus-1/myCustomDbus.conf --print-address
like image 158
oOnez Avatar answered Oct 15 '22 13:10

oOnez


You should use a startup script. The "run" command is executed only when the container is created and then stopped.

like image 27
sdhd Avatar answered Oct 15 '22 13:10

sdhd