How to "avahi-view" from a docker container?

I am running a ubuntu: 14.04 based container and I need to be able to use avahi-browse

inside of it. However:

(.env)root@8faa2c44e53e:/opt/cluster-manager# avahi-browse -a
Failed to create client object: Daemon not running
(.env)root@8faa2c44e53e:/opt/cluster-manager# service avahi-daemon status
Avahi mDNS/DNS-SD Daemon is running

      

The actual problem I am facing is an error pybonjour

; pybonjour.BonjourError: (-65537, 'unknown')

but I read what is related to the problem with avahi-daemon.

So how to connect to avahi-daemon from container?

PS I need to disable dbus in populating avahi-daemon.conf in order to start it, otherwise avahi-daemon won't start with dbus error like this: (.env)root@8faa2c44e53e:/opt/cluster-manager# avahi-daemon Found user 'avahi' (UID 103) and group 'avahi' (GID 107). Successfully dropped root privileges. avahi-daemon 0.6.31 starting up. dbus_bus_get_private(): Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory WARNING: Failed to contact D-Bus daemon. avahi-daemon 0.6.31 exiting.

+3


source to share


3 answers


Avahi requires D-BUS to communicate with customers. It looks like your docker container is not starting the D-BUS system. If you do, then Avahi should work.



You need D-BUS for most Avahi features (including avahi-browse), so turning it off won't help.

0


source


There is a docker image supposedly supporting avahi from a container. The trick seems to be to mount / var / run / dbus from host to container.



Please note that I could not get this image to work on my 16.04. host.

0


source


I faced the same issue where avahi and dbus worked correctly on Ubuntu 14.04 (in particular, I was trying to use ROS TurtleBot). I solved this by including a modified version of the instructions in docker-systemd in my Dockerfile :

FROM ubuntu:14.04
RUN apt-get update &&\
    apt-get install -y avahi-utils avahi-daemon libnss-mdns systemd
RUN cd /lib/systemd/system/sysinit.target.wants/;\
  ls | grep -v systemd-tmpfiles-setup | xargs rm -f $1 \
    rm -f /lib/systemd/system/multi-user.target.wants/*;\
  rm -f /etc/systemd/system/*.wants/*;\
  rm -f /lib/systemd/system/local-fs.target.wants/*; \
  rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
  rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
  rm -f /lib/systemd/system/basic.target.wants/*;\
  rm -f /lib/systemd/system/anaconda.target.wants/*; \
  rm -f /lib/systemd/system/plymouth*; \
  rm -f /lib/systemd/system/systemd-update-utmp*
RUN mkdir -p /var/run/dbus
ENV init /lib/systemd/systemd

      

After modifying your Dockerfile to include these instructions, you must create a container using the following command:

docker run --rm --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro -it <DOCKER_IMAGE> /bin/bash

      

Finally, once you get into the container, you must run the following commands before trying to use avahi-browse (directly or indirectly):

$ dbus-service --system
$ /etc/init.d/avahi-daemon start

      

0


source







All Articles