diff options
author | Kelley Spoon <kelley.spoon@linaro.org> | 2018-02-18 00:57:51 -0600 |
---|---|---|
committer | Kelley Spoon <kelley.spoon@linaro.org> | 2018-02-21 15:32:16 -0600 |
commit | e86dc867d46edcfc47fa616886650693036d0e23 (patch) | |
tree | 21d2c006db302cd81ffeacdc87b63ea8b034632c | |
parent | 0a404125ce00f966f97838f19fc256d484e25cb0 (diff) |
Dockerfile: Add devdns container.
This adds a docker container that will automatically
build and update local DNS information based on
containers running in docker. As containers are
brought online DNS entries are created to tie their
IP address to "<container_name>.dev".
If a container is launched with a -e ALIAS argument,
that alias will be added to the DNS entry for the container.
Change-Id: I443e5443cbb1dac540b8fa85fba5b9de7fae656d
-rwxr-xr-x | build.sh | 1 | ||||
-rw-r--r-- | devdns/Dockerfile | 27 | ||||
-rw-r--r-- | devdns/Procfile | 2 | ||||
-rw-r--r-- | devdns/devdns.cfg | 5 | ||||
-rw-r--r-- | devdns/dnsmasq.conf | 6 | ||||
-rw-r--r-- | devdns/dnsmasq.hosts.conf.tmpl | 5 | ||||
-rw-r--r-- | devdns/resolv.conf | 4 |
7 files changed, 50 insertions, 0 deletions
@@ -1,6 +1,7 @@ docker build -t ansible/baseimage:14.04 -f Dockerfile_trusty . & docker build -t ansible/baseimage:16.04 -f Dockerfile_xenial . & docker build -t linaro/login-proxy -f Dockerfile_login_proxy . & +(cd devdns; docker build -t linaro/devdns -f Dockerfile . ) & wait echo "Build complete" diff --git a/devdns/Dockerfile b/devdns/Dockerfile new file mode 100644 index 0000000..ab15518 --- /dev/null +++ b/devdns/Dockerfile @@ -0,0 +1,27 @@ +FROM jwilder/docker-gen + +VOLUME /tmp/dns.sock + +RUN apk add --no-cache dnsmasq bash wget +RUN mkdir /app + +ADD https://github.com/jwilder/forego/releases/download/v0.16.1/forego /usr/local/bin/forego +RUN chmod u+x /usr/local/bin/forego + +ADD devdns.cfg /app/devdns.cfg +ADD dnsmasq.conf /etc/dnsmasq.conf +ADD resolv.conf /etc/resolv.conf +ADD dnsmasq.hosts.conf.tmpl /app/dnsmasq.hosts.conf.tmpl +ADD Procfile /app/Procfile + +WORKDIR /app +ENTRYPOINT ["/usr/local/bin/forego","start","-r" ] + +# Create a DNS container that will automatically +# create and update DNS entries for all containers +# running on the host. +# +# Requires start using -v /var/run/docker.sock:/tmp/docker.sock +# +# Any container startd with a -e ALIAS arg will have that +# alias associated with it's IP address diff --git a/devdns/Procfile b/devdns/Procfile new file mode 100644 index 0000000..e7f4e1a --- /dev/null +++ b/devdns/Procfile @@ -0,0 +1,2 @@ +dockergen: docker-gen -config /app/devdns.cfg +dnsmas: dnsmasq -d diff --git a/devdns/devdns.cfg b/devdns/devdns.cfg new file mode 100644 index 0000000..de6bb0d --- /dev/null +++ b/devdns/devdns.cfg @@ -0,0 +1,5 @@ +[[config]] +watch = true +notifycmd = "kill -HUP $(pidof dnsmasq)" +template = "/app/dnsmasq.hosts.conf.tmpl" +dest = "/etc/alias_hosts" diff --git a/devdns/dnsmasq.conf b/devdns/dnsmasq.conf new file mode 100644 index 0000000..c4d70b9 --- /dev/null +++ b/devdns/dnsmasq.conf @@ -0,0 +1,6 @@ +domain-needed +bogus-priv +user=root +no-dhcp-interface=0.0.0.0 +addn-hosts=/etc/alias_hosts +conf-dir=/etc/dnsmasq.d/,*.conf diff --git a/devdns/dnsmasq.hosts.conf.tmpl b/devdns/dnsmasq.hosts.conf.tmpl new file mode 100644 index 0000000..1923784 --- /dev/null +++ b/devdns/dnsmasq.hosts.conf.tmpl @@ -0,0 +1,5 @@ +{{$domain := "dev" }} +{{range $index, $container := . }} + {{ $network := index $container.Networks 0 }} +{{$network.IP}} {{$container.Name}} {{$container.Name}}.{{$domain}}{{ when (contains $container.Env "ALIAS") (printf " %s" $container.Env.ALIAS) ""}} +{{end}} diff --git a/devdns/resolv.conf b/devdns/resolv.conf new file mode 100644 index 0000000..bb9cf73 --- /dev/null +++ b/devdns/resolv.conf @@ -0,0 +1,4 @@ +domain linaro.dev +nameserver 127.0.0.1 +nameserver 8.8.8.8 +nameserver 8.8.4.4 |