Docker Mdns Save

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

Project README

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

Open Source Agenda is not affiliated with "Docker Mdns" Project. README Source: Jack12816/docker-mdns
Stars
26
Open Issues
1
Last Commit
6 years ago

Open Source Agenda Badge

Open Source Agenda Rating