How do I advertise and view mDNS from a docker container?

I am trying to create a docker container based on Ubuntu 17.04 that can view mDNS on my network (outside of the docker network) AND advertise mDNS on my network (outside the docker network).

I want to be able to run this docker container on macOS host (during my development) and Linux (Debian) host to build.

https://github.com/ianblenke/docker-avahi seems to have solved this for Linux hosts (using avahi daemon and mapping / var / run / dbus volume from hosts). When I am developing my macbook I would like to use mDNSResponder.

How do I create a container that can advertise and view my local network that will also work on my macOS laptop and Linux server?

Here's what I have so far.

Dockerfile

FROM ubuntu:17.04    
WORKDIR /app

RUN apt-get update && apt-get install -yq avahi-daemon avahi-utils libnss-mdns \
  && apt-get -qq -y autoclean \
  && apt-get -qq -y autoremove \
  && apt-get -qq -y clean

RUN update-rc.d avahi-daemon enable

COPY docker/etc/nsswitch.conf /etc/nsswitch.conf
COPY docker/etc/avahi-daemon.conf /etc/avahi/avahi-daemon.conf

COPY docker/start.sh /app    

CMD ["/bin/bash","start.sh"]

      

start.sh

#!/bin/bash

service avahi-daemon restart
service avahi-daemon status
avahi-browse -a

      

nsswitch.conf

hosts: files mdns_minimal [NOTFOUND=return] dns

Avahi-daemon.conf

...
enable-dbus=no
...

      

Running

docker run --net=host -it mdns1
 * Restarting Avahi mDNS/DNS-SD Daemon avahi-daemon                      [ OK ]
Avahi mDNS/DNS-SD Daemon is running
Failed to create client object: Daemon not running

      

As you can see, avahi-daemon works, but avahi-browse

it doesn't think it is. Is it because I disabled dbus?

Running the same commands (except what I save enable-dbus=yes

) inside the 17.04 virtual camera image on my macros works fine.

Update: It looks like you may not be bridging the macOS host . So am I trying to make it impossible?

+4


source to share


2 answers


I am currently trying to get avahi to work inside a docker container and came across this in my research:

you can disable dbus in the Avahi settings configuration so that it does not use it. Then when you run Avahi in Docker, you must pass --no-rlimits to it and it will work without compromising the security of your containers.



https://www.reddit.com/r/docker/comments/54ufz2/is_there_any_way_to_run_avahi_in_docker_without/

Hope this helps in your situation.

+1


source


For advertising / listening on mdns, we run dnssd inside Docker containers .

But! For detection on the local network, the docker container must have an IP address from the network, the correct routes must be configured from the network to the docker container.



If you don't have control over the default network router, you can try using the macvlan / ipvlan network driver. This will allow you to assign multiple mac / IP addresses on the same network interface.

In our case, the Wi-Fi network, so we had to use ipvlan because Macvlan does not work with Wi-Fi. In the wired case, you should prefer Macvlan.

0


source







All Articles