Skip to content

Listen docker events to update dnsmasq hosts configuration

License

Notifications You must be signed in to change notification settings

mveyrenc/docker-listen

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Intro

docker-listen provides automatic dnsmasq hosts configuration update on docker run and stop events.

Installation

docker-listen relies on following dependencies :

  • dpath
  • docker-py

You can install these dependencies by your regular packaging system.

Otherwise, you can use virtualenv and pip to prepare an isolated python env :

virtualenv docker-listen-pyenv
./docker-listen-pyenv/bin/pip install dpath
./docker-listen-pyenv/bin/pip install docker-py

<python> refers to an interpreter loaded with needed dépendencies.

Running

Run the following command :

sudo <python> docker-listen.py

pex enables one-line install / run :

sudo pex dpath docker-py -- docker-listen.py

WARN : /etc/dnsmasq.d/docker-* will be cleared each time process is started.

WARN : sudo is required so that docker-listen can force dnsmasq to reload hosts (with a SIGHUP process signal)

Running as a service

Using upstart

Copy the file upstart/docker-listen.conf in /etc/init.

Configure the path to docker-listen in /etc/init/docker-listen.conf and start the service with service docker-listen start.

Using Systemd

Copy the file systemd/docker-listen.service in /lib/systemd/system.

Fix permission chmod a+x /lib/systemd/system/docker-listen.service

Enable the unit systemctl enable docker-listen.service.

Start it systemctl start docker-listen.service.

and see if it's running correctly systemctl status docker-listen.service.

Configuration

sudo <python> docker-listen.py

Options can be loaded from a python .ini configuration file provided with -c command line option.

Example :

[docker-listen]
hosts_domain_name=docker.openwide.fr
hosts_dir=/etc/dnsmasq.d
docker_url=unix://var/run/docker.sock
sighup_enabled=yes
sighup_process_name=dnsmasq
log_level=WARN

Usage

Add the label com.docker-listen.dnsmasq-hostname on your containers.

About

Listen docker events to update dnsmasq hosts configuration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%