From b4b29fabddaca108f341342d3795ad8a6d949999 Mon Sep 17 00:00:00 2001 From: Leonid Makarov Date: Fri, 20 Jan 2017 14:59:44 -0800 Subject: [PATCH] Cleanup - README docs - Removed MAINTAINER in Dockerfile as soon to be deprecated --- Dockerfile | 2 -- README.md | 65 +++++++++++++++++++++++++++++++++++++++++++++-- conf/dnsmasq.tmpl | 2 +- 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 012d3a3..b1bb415 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,5 @@ FROM alpine:3.4 -MAINTAINER Team Docksal, https://docksal.io - RUN apk add --no-cache \ curl \ supervisor \ diff --git a/README.md b/README.md index ce52777..dfc4783 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,66 @@ # DNS Docker image for Docksal -docker-gen generates a configuration for dnsmasq and reloads it when containers are started and stopped. - This image(s) is part of the [Docksal](http://docksal.io) image library. + +Provides wildcard domain name resolution for local development. + +## Features + +- Wildcard domain name resolution +- Service discovery for containers + +### Wildcard domain name resolution + +```bash +$ docker run --name dns -d -e DNS_DOMAIN=docksal -e DNS_IP=192.168.64.100 -e docksal/dns + +$ nslookup something.docksal 192.168.64.100 +Server: 192.168.64.100 +Address: 192.168.64.100#53 + +Name: something.docksal +Address: 192.168.64.100 +``` + +Replace `192.168.64.100` with your Docker host IP. + +### Service discovery for containers + +This image has docker-gen built-in. Whenever containers start or stop the DNS configuration will be updated. + +User either the `DNS_NAME` environment variable or the `dns.name` label with your containers to assign them +an arbitrary domain name. The assigned domain name will be resolved to the container's internal IP address. + +```bash +docker run --name dns-test -d -e DNS_NAME=test.mydomain.com busybox top + +$ nslookup test2.mydomain2.com 192.168.64.100 +Server: 192.168.64.100 +Address: 192.168.64.100#53 + +Name: test2.mydomain2.com +Address: 172.17.0.5 +``` + +```bash +$ docker run --name dns-test2 -d --label dns.name=test2.mydomain2.com busybox top + +$ nslookup test.mydomain.com 192.168.64.100 +Server: 192.168.64.100 +Address: 192.168.64.100#53 + +Name: test.mydomain.com +Address: 172.17.0.6 +``` + +Replace `192.168.64.100` with your Docker host IP. + +## Debugging + +Launch the container with `LOG_QUERIES=true` to enabled query logging. + +```bash +docker run --name dns -d -e DNS_DOMAIN=docksal -e DNS_IP=192.168.100.64 -e LOG_QUERIES=true docksal/dns +``` + +View logs with `docker logs dns` diff --git a/conf/dnsmasq.tmpl b/conf/dnsmasq.tmpl index 481b0d6..b28c53e 100644 --- a/conf/dnsmasq.tmpl +++ b/conf/dnsmasq.tmpl @@ -16,7 +16,7 @@ address=/{{ $host }}/{{ $network.IP }} {{ end }} {{ end }} -{{/* Configuration via "DNS_NAME" envitonment variables */}} +{{/* Configuration via "DNS_NAME" environment variables */}} {{ range $host, $containers := groupByMulti $ "Env.DNS_NAME" "," }} {{ range $index, $container := $containers }} {{ template "host" (dict "Container" $container "Host" (print $host) "Tld" "") }}