I've made a Docker container which runs a forked-daapd (a DAAP server publishing over mDNS with a single port 3689 for HTTP requests) and exposes the port properly to the host operating system:

sudo docker run -it --rm -v /home/naftuli/Music:/srv/music -p 3689:3689 \
    daapd /sbin/my_init

The problem is that this service never gets published properly to mDNS because its IP address (some internal Docker IP range) doesn't really work. I could run it with --net=host, but that's potentially pretty dangerous as I'm basically handing my network adapter to the container.

Is there a way for me to publish this service and have mapping work as planned?

1 Answer 1


The problem of dockerising mDNS services (e.g. Avahi etc.) is that service should be aware of its public IP address in order to advertise it. As far as I'm aware the only way to address this problem is to assign public IP to the container (which is a little bit tricky due to lack of support for static IP assignment in Docker).

This article describes technique how it can be done on Debian:

  1. Docker service should be started with DOCKER_OPTS="--bridge=br0 --ip-masq=false --iptables=false". I assume that br0 bridge is already configured.

  2. Container should be started with --cap-add=NET_ADMIN --net=bridge

  3. Inside container pre-up ip addr flush dev eth0 in /etc/network/interfaces can be used to dismiss IP address assigned by Docker as in following example:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
    pre-up ip addr flush dev eth0
  1. Container's entry script should begin with /etc/init.d/networking start. Also entry script needs to edit or populate /etc/hosts file in order to remove references to Docker-assigned IP.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .