• Stars
    star
    185
  • Rank 208,271 (Top 5 %)
  • Language
    Go
  • License
    GNU General Publi...
  • Created about 10 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a direct, raw DNS interface to the Docker API

rawdns

Save as /etc/rawdns/config.json:

{
	"docker.": {
		"type": "containers",
		"socket": "unix:///var/run/docker.sock"
	},
	"local.": {
		"type": "forwarding",
		"nameservers": [ "192.168.1.1" ]
	},
	".": {
		"type": "forwarding",
		"nameservers": [ "8.8.8.8", "8.8.4.4" ]
	}
}

Then:

$ docker run --rm -p 53:53/udp -v /var/run/docker.sock:/var/run/docker.sock -v /etc/rawdns/config.json:/etc/rawdns/config.json:ro tianon/rawdns rawdns /etc/rawdns/config.json
2014/09/23 14:46:10 listening on domain: docker.
2014/09/23 14:46:10 listening on domain: local.
2014/09/23 14:46:10 listening on domain: .

The most-specific domain gets the request (ie, if you have both docker. and containers.docker. and you do a lookup for something.containers.docker, you'll get back the IP of the container named something).

The default configuration only includes docker. going to /var/run/docker.sock and . going to 8.8.8.8+8.8.4.4.

wat

Since DNS is a protocol (which is a type of API), and Docker has an API, it makes a lot more sense to have DNS be a raw interface to Docker than it does to treat DNS like a database and try to synchronize the two data sources.

why

I've eventually grown to dislike every "Docker DNS" project for one reason or another, and usually the misgivings boil down to treating DNS like a database, which reminds me of my favorite thing to say about databases: if you have the same data in two places, they are guaranteed to eventually get out of sync in some way (no matter how clever you or your code are).

how

This is implemented by borrowing the core of SkyDNS, github.com/miekg/dns. It's a really great, but very raw, DNS library for Go that makes it really easy to write a DNS server or client. One of the explicit design goals of the project is "If there is stuff you should know as a DNS programmer there isn't a convenience function for it."

SHOW ME

$ dig @localhost dns.docker

; <<>> DiG 9.9.5 <<>> @localhost dns.docker
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18138
;; flags: qr rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available

;; QUESTION SECTION:
;dns.docker.			IN	A

;; ANSWER SECTION:
dns.docker.		0	IN	A	172.18.0.30

;; Query time: 1 msec
;; SERVER: ::1#53(::1)
;; WHEN: Wed Sep 24 23:06:33 MDT 2014
;; MSG SIZE  rcvd: 54

$ ping dns.docker
PING dns.docker (172.18.0.30) 56(84) bytes of data.
64 bytes from 172.18.0.30: icmp_seq=1 ttl=64 time=0.025 ms
64 bytes from 172.18.0.30: icmp_seq=2 ttl=64 time=0.049 ms
64 bytes from 172.18.0.30: icmp_seq=3 ttl=64 time=0.041 ms
^C
--- dns.docker ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 0.025/0.038/0.049/0.011 ms

swarm support

rawdns can be used with swarm by creating a configuration that provides the socket details using the tcp:// scheme. You will also need to enable swarmnode by setting it to true. The swarmnode option enables rawdns to look at the Node section of the inspect API response for the external/host IP address.

Example swarm configuration:

{
    "swarm.": {
        "type": "containers",
        "socket": "tcp://192.168.99.100:3376",
        "swarmnode": true,
        "tlsverify": true,
        "tlscacert": "/var/lib/boot2docker/ca.pem",
        "tlscert": "/var/lib/boot2docker/server.pem",
        "tlskey": "/var/lib/boot2docker/server-key.pem"
    },
    "docker.": {
        "type": "containers",
        "socket": "unix:///var/run/docker.sock"
    },
    "local.": {
        "type": "forwarding",
        "nameservers": [ "172.17.42.1" ]
    },
    ".": {
        "type": "forwarding",
        "nameservers": [ "8.8.8.8", "8.8.4.4" ]
    }
}

Example usage:

$ docker run --name dns --rm -it \
    -p 53:53/udp \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v /var/lib/boot2docker:/var/lib/boot2docker \
    -v /etc/rawdns/config.json:/etc/rawdns/config.json:ro \
    tianon/rawdns rawdns /etc/rawdns/config.json

2015/09/14 21:50:49 rawdns v1.2 (go1.4.2 on linux/amd64; gc)
2015/09/14 21:50:49 listening on domain: .
2015/09/14 21:50:49 listening on domain: swarm.
2015/09/14 21:50:49 listening on domain: docker.
2015/09/14 21:50:49 listening on domain: local.

...

$ docker run -it debian:jessie bash

root@69967c3e5179:/# ping redis.swarm
PING redis.swarm (192.168.99.101): 56 data bytes
64 bytes from 192.168.99.101: icmp_seq=0 ttl=63 time=0.001 ms

root@69967c3e5179:/# ping dns.swarm
PING dns.swarm (192.168.99.100): 56 data bytes
64 bytes from 192.168.99.100: icmp_seq=0 ttl=64 time=0.030 ms

root@69967c3e5179:/# ping dns.docker
PING dns.docker (172.17.0.85): 56 data bytes
64 bytes from 172.17.0.85: icmp_seq=0 ttl=64 time=0.076 ms

More Repositories

1

gosu

Simple Go-based setuid+setgid+setgroups+exec
Shell
4,679
star
2

dockerfiles

A semi-random collection of odds and ends.
Dockerfile
1,042
star
3

docker-postgres-upgrade

a PoC for using "pg_upgrade" inside Docker -- learn from it, adapt it for your needs; don't expect it to work as-is!
Shell
1,039
star
4

docker-brew-ubuntu-core

DEPRECATED; see https://github.com/tianon/docker-brew-ubuntu-core/pull/248
Shell
586
star
5

cgroupfs-mount

Simple (outdated) scripts to mount the cgroupfs (v1) hierarchy, especially structured for Debian packaging
Shell
193
star
6

docker-qemu

Dockerization of supported QEMU releases
Shell
120
star
7

docker-brew-debian

DEPRECATED in favor of https://github.com/debuerreotype/docker-debian-artifacts
Shell
114
star
8

gosleep

"sleep(1)", but with Go duration parsing OR explicit time to sleep until and a progress bar
Go
95
star
9

docker-bash

Many versions of Bash, Dockerized
Shell
58
star
10

boot2docker-debian

a newly re-imagined boot2docker, based on Debian for stability and maintainability
Shell
55
star
11

docker-overlay

Gentoo overlay for Docker
Shell
51
star
12

docker-syncthing

Dockerization of supported versions of the popular syncthing utility (https://syncthing.net)
Shell
38
star
13

docker-bin

A small collection of useful scripts (lives in my PATH)
Shell
33
star
14

pgp-happy-eyeballs

DEPRECATED; like "happy eyeballs" (ipv4/ipv6), but for flaky PGP gossip servers
Go
33
star
15

squignix

NGINX, configured to act like Squid
Dockerfile
28
star
16

docker-dind-cluster

simple docker-compose setup for running a quick Docker-in-Docker Swarm cluster for testing
19
star
17

debian-golang-pty

https://anonscm.debian.org/cgit/pkg-go/packages/golang-pty.git
Go
17
star
18

gentoo-overlay

Shell
15
star
19

debian-golang-dbus

https://anonscm.debian.org/cgit/pkg-go/packages/golang-dbus.git
Go
15
star
20

jenkins-groovy

Just a collection of my Jenkins Groovy nonsense (especially Job DSL scripts)
Groovy
13
star
21

vim-docker

An automatic mirror of Vim Dockerfile syntax files (see README)
11
star
22

home

dotfiles
Shell
10
star
23

linux-rtlwifi-8188ce

A mirror of the "official" Realtek kernel module for the 8188CE (and others) - note that this driver is really no better or worse than the one directly in-kernel, since the driver can't fix horrid hardware. This also probably doesn't compile properly on newer kernels.
C
9
star
24

docker-brew-ubuntu

OLD SOURCE OF STACKBREW IMAGES
Shell
8
star
25

mirror-refind

Mirror of https://git.code.sf.net/p/refind/code (https://sourceforge.net/p/refind/code)
C
8
star
26

docker-brew-ubuntu-debootstrap

DEPRECATED
Shell
8
star
27

debian-security-tracker-mirror

DEPRECATED in favor of https://salsa.debian.org/security-tracker-team/security-tracker/tree/master/data
Shell
8
star
28

docker-gentoo-stage3

Shell
7
star
29

debian-moby

Debian packaging for Docker bits (Docker CLI, Engine, containerd, etc.)
Makefile
7
star
30

docker-moosefs

Dockerization of supported versions of MooseFS (https://moosefs.com/) + a Dockerized Docker volume driver
Go
7
star
31

bash

Mirror of https://git.savannah.gnu.org/cgit/bash.git
C
5
star
32

go-progress

simple Go progress bar inspired by PyPi's "progress" package
Go
4
star
33

musl

Mirror of http://git.musl-libc.org/cgit/musl
C
4
star
34

docker-brew-cirros

Imports of the CirrOS tarballs for use in Docker
Shell
4
star
35

go-aptsources

WIP package to deal with apt sources, especially generating "sources.list"; see also https://pault.ag/go/debian
Go
4
star
36

debian-bin

A collection of scripts/utilities to help with various Debian packaging prep and building
Shell
4
star
37

uscan-helper

https://wiki.debian.org/debian/watch
Go
4
star
38

pinkpogo-scripts

Useful scripts for Debian on my PogoPlug which may or may not be pinkpogo-specific - use at your own risk.
Shell
4
star
39

debian-golang-gocapability

https://anonscm.debian.org/cgit/pkg-go/packages/golang-gocapability-dev.git
Go
3
star
40

dockerhub-public-proxy

A simple proxy for public Docker Hub resources to improve their explicit cacheability
Perl
3
star
41

gdbuild

"docker build" for Debian packages
Go
3
star
42

debian-docker

https://anonscm.debian.org/cgit/docker/docker.io.git
3
star
43

abstract-sockets

An attempt to document the types of applications which might be using abstract sockets by default. PLEASE READ THE README (esp. the bit about responsible disclosure).
3
star
44

docker-tini-tags

Mapping Docker releases to tini commits (https://github.com/tianon/docker-tini-tags/tags)
2
star
45

docker-machine-driver-triton

Go
2
star
46

docker-elk-stack

2
star
47

debian-rawdns

https://anonscm.debian.org/cgit/docker/rawdns.git
Go
2
star
48

one

The "One" True Way (this was a misguided experiment -- don't use it!)
Shell
2
star
49

tianon.github.io

Tianon's Ramblings ✿
CSS
2
star
50

backups3

(abandon-ware; school project) Performs backups to Amazon's S3 service.
Perl
2
star
51

debian-golang-go-systemd

https://anonscm.debian.org/cgit/pkg-go/packages/golang-go-systemd.git
Go
2
star
52

cirros

(DEPRECATED) Mirror of https://git.launchpad.net/cirros
2
star
53

2016-container-summit-vegas

My talk "slides" from Container Summit 2016 in Las Vegas, NV
C
2
star
54

debian-runc

https://anonscm.debian.org/cgit/pkg-go/packages/runc.git
1
star
55

rouge

(abandon-ware) A remote server incremental backup system (using git) for performing backups of many computers easily and centrally.
Perl
1
star
56

foobar

DO NOT USE
Shell
1
star
57

munin-plugins

A collection of the public Munin plugins I've written or adapted in some way.
Perl
1
star
58

docker-dart-sample

Dockerfile
1
star
59

docker-prometheus-example

1
star
60

docker-deb-vendored

a mockup of Debian packaging which vendors _all_ components of Docker including Go itself (using multiorig tarballs)
1
star
61

containerd-registry

A basic OCI registry built on top of containerd's image/content store
Go
1
star
62

dtodo

rough "TODO" list generator for in-progress Debian packages
Go
1
star
63

docker-brew-alpine-multiarch

PROOF OF CONCEPT ONLY -- this is a PoC to show off what an official-images multiarch Alpine repo might look like
Shell
1
star
64

docker-runc-tags

Mapping Docker releases to runc commits (https://github.com/tianon/docker-runc-tags/tags)
1
star
65

docker-libnetwork-tags

Mapping Docker releases to libnetwork commits (https://github.com/tianon/docker-libnetwork-tags/tags)
1
star
66

aufs-util

(DEPRECATED) Mirror of https://git.code.sf.net/p/aufs/aufs-util
1
star
67

docker-museum

Shell
1
star
68

debian-containerd

https://anonscm.debian.org/cgit/pkg-go/packages/containerd.git
Go
1
star
69

docker-containerd-tags

Mapping Docker releases to containerd commits (https://github.com/tianon/docker-containerd-tags/tags)
1
star
70

bashbrew-tianon

Shell
1
star