relateiq/node-docker-machine-dns

Name: node-docker-machine-dns

Owner: SalesforceIQ

Description: Runs a tiny A-Record DNS server that runs hostnames thru $(docker-machine ip NAME) to resolve

Created: 2015-10-08 19:43:28.0

Updated: 2018-05-13 14:56:49.0

Pushed: 2016-06-01 18:41:15.0

Homepage: null

Size: 16

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

docker-machine DNS server

This package fires up a tiny (~100 lines) DNS server whose sole purpose is to listen for *.docker DNS lookups and resolve the hostname using docker-machine ip.

How it works:

Environment variables

DOCKER_MACHINE_DNS_RESOLVER

Change the default IP resolver from docker-machine ip to your own custom command by setting this environment variable.

DOCKER_MACHINE_DNS_TLD

Change the default tld from docker by setting this environment variable.

Setup:

Install in the usual way:

install -g docker-machine-dns
Setup: The easy way

Run this:

 mkdir -p /etc/resolver
 touch /etc/resolver/docker
 chown -R $USER /etc/resolver       

This creates the /etc/resolver directory (if it doesn't already exist) and grants ownership to your current user account. The service will automatically configure the resolver/docker file on each run, making it “just work”.

Setup: The way that doesn't require changing ownership of /etc/resolver

Write this to /etc/resolver/docker and always run with the same specified port

server  127.0.0.1
    12345
ch_order    300000
out 1

Note: the whitespace separators in this file NEED to be tabs. Spaces won't work.

Example:
cker-machine ls
   ACTIVE   DRIVER       STATE     URL                         SWARM
            virtualbox   Running   tcp://192.168.99.100:2376
            virtualbox   Running   tcp://192.168.99.101:2376
            virtualbox   Stopped

ng -t 4 dev.docker
: cannot resolve dev.docker: Unknown host

cker-machine-dns &
18007
ening on UDP port 55451

ng -t 4 dev.docker
 dev.docker (192.168.99.100): 56 data bytes
ytes from 192.168.99.100: icmp_seq=0 ttl=64 time=0.268 ms
ytes from 192.168.99.100: icmp_seq=1 ttl=64 time=0.272 ms
ytes from 192.168.99.100: icmp_seq=2 ttl=64 time=0.313 ms
ytes from 192.168.99.100: icmp_seq=3 ttl=64 time=0.454 ms

dev.docker ping statistics ---
ckets transmitted, 4 packets received, 0.0% packet loss
d-trip min/avg/max/stddev = 0.268/0.327/0.454/0.076 ms

ng -t 4 dev2.docker
 dev2.docker (192.168.99.101): 56 data bytes
ytes from 192.168.99.101: icmp_seq=0 ttl=64 time=0.232 ms
ytes from 192.168.99.101: icmp_seq=1 ttl=64 time=0.394 ms
ytes from 192.168.99.101: icmp_seq=2 ttl=64 time=0.284 ms
ytes from 192.168.99.101: icmp_seq=3 ttl=64 time=0.222 ms

dev2.docker ping statistics ---
ckets transmitted, 4 packets received, 0.0% packet loss
d-trip min/avg/max/stddev = 0.222/0.283/0.394/0.068 ms

docker-machine-dns can take a UDP port as its first (and only) argument to bind to that specific port instead of randomly picking one on each run.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.