Jack12816/docker-mdns


Simple mDNS/ZeroConf demonstration of a nginx container, acessible at http://nginx.local

Language: Makefile

Keywords: docker, docker-compose, make, mdns, nginx, zeroconf


Docker mDNS Demo

This prototype is dedicated to demonstrate the setup of Docker containers which are accessible by mDNS addresses. The regular ZeroConf TLD is .local. So with the help of this demo you can learn how to setup a new container and make it available as nginx.local.

Requirements

  • Docker (>=17.06.0-ce) (lower should work, too)
  • Docker Compose (>=1.15.0) (lower should work, too)
  • GNU Make (>=4.2.1)
  • jq (>=1.5)
  • Host enabled Avahi daemon
  • Host enabled mDNS NSS lookup

Getting started

All you need to to is to run the following command:

$ make start

This command will take care of downloading the nginx:latest docker image and building the custom image on top of it. Afterwards the new image will be booted.

Start a second terminal and type the following command to verify your host configuration:

$ make test

If everything is fine, you will see something like this:

# Test the IP/mDNS setup
#
# > Container ip: 172.17.0.2
#
# DNS resolution test (nginx.local):
PING nginx.local (172.17.0.2) 56(84) bytes of data.
64 bytes from 172.17.0.2 (172.17.0.2): icmp_seq=1 ttl=64 time=0.062 ms
64 bytes from 172.17.0.2 (172.17.0.2): icmp_seq=2 ttl=64 time=0.053 ms
64 bytes from 172.17.0.2 (172.17.0.2): icmp_seq=3 ttl=64 time=0.102 ms
64 bytes from 172.17.0.2 (172.17.0.2): icmp_seq=4 ttl=64 time=0.079 ms

--- nginx.local ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3034ms
rtt min/avg/max/mdev = 0.053/0.074/0.102/0.018 ms
#
# Test was successful. Yay.

If the test fails, read on.

Host configs

Install the nss-mdns package, enable and start the avahi-daemon.service. Then, edit the file /etc/nsswitch.conf and change the hosts line like this:

hosts: ... mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns ...

Further reading

Project Statistics

Sourcerank 2
Repository Size 131 KB
Stars 2
Forks 0
Watchers 0
Open issues 0
Dependencies 0
Contributors 1
Tags 0
Created
Last updated
Last pushed

Top Contributors See all

Hermann Mayer

Something wrong with this page? Make a suggestion

Last synced: 2018-01-25 19:31:46 UTC

Login to resync this repository