Code Monkey home page Code Monkey logo

docker-autodns's Introduction

License MIT

autodns

docker-autodns sets up a container running dnsmasq and docker-gen. The container uses docker-gen to reconfigure dnsmasq as other containers are started and stopped. Configured correctly, this container will allow other containers to address each other by name alone, e.g. If you're running a container with the name mycontainer which is serving a HTTP API on port 8080, then from another container on the same host you can simply curl http://mycontainer:8080 to contact it.

autodns is a simple solution for a specific usecase and does not attempt to replace more fully featured systems like skydns which you should definitely check out if autodns doesn't meet your needs.

Prerequisites

In order for autodns to work, the docker daemon must be started with a few special options, you'll need to explicitly specify a bridge IP and tell docker to use that for DNS resolution inside containers. It's also useful to explicitly specify some external DNS servers should your local DNS service be unreachable for any reason.

$ docker -d --bip=172.17.42.1/16 --dns=172.17.42.1 --dns=8.8.8.8 --dns=8.8.4.4

If you're using an Upstart based system (Ubuntu/Debian, at least until the systemd switchover), then the easiest way to do this is to modify docker's startup scripts inside /etc/init/. You should ensure that /etc/default/docker contains the following line (note the inclusion of Google's public DNS servers):

DOCKER_OPTS="--bip=172.17.42.1/16 --dns=172.17.42.1 --dns=8.8.8.8 --dns=8.8.4.4"

and then just restart the docker service:

$ sudo service docker restart

Instructions for other init systems (sysV/systemd/etc) may differ. These will hopefully be added soon.

Usage

To run it:

$ docker run -d -p 0.0.0.0:53:53/udp -v /var/run/docker.sock:/var/run/docker.sock rehabstudio/autodns

Then start any containers you need, no special options are required:

$ docker run -d --name mycontainer somerepo/somecontainer

You should then be able to use the local DNS service from inside a container:

$ docker run -ti ubuntu bash
$ ping mycontainer
64 bytes from mycontainer (172.17.0.25): icmp_seq=1 ttl=64 time=0.075 ms
64 bytes from mycontainer (172.17.0.25): icmp_seq=1 ttl=64 time=0.042 ms

Building autodns locally

If you're planning to customise autodns, whether to submit a patch or just to customise a private build, the easiest way to do so is to clone this repo locally, build a private copy and push to a docker registry using a different repo/name.

Building this container uses docker's standard process, nothing special:

$ docker build -t autodns .

As always, pull requests are very welcome.

docker-autodns's People

Stargazers

Iskandar Najmuddin avatar  avatar Bruno Wego avatar Simon Elsbrock avatar

Watchers

Peter Gasston avatar Patrick Carey avatar Josh Noble avatar Chris Grant avatar James Cloos avatar Roger Simms avatar Mark McConnell avatar Kirsty McCrystal avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.