Service that automatically updates your /etc/hosts file based on your running docker containers.
Switch branches/tags
Nothing to show
Clone or download
Latest commit 0263c92 Nov 1, 2018


docker_hosts_update is a small program that automatically updates your /etc/hosts file, giving your docker containers hostnames.

By default the containers will be given a hostname of {container name}.{network name}. E.g. The hello-world container running in the corp.internal network and the nginx container running in the default bridge network will be written to your hosts file something like the following.   hello-world.corp.internal   nginx.bridge


sudo pip3 install -U "git+"


Usage: docker_hosts_update [OPTIONS]

  Program that automatically updates your `/etc/hosts` file based on your
  running docker containers.

  --hosts-file TEXT    The hosts file to update.
  --once               Run the update script once only.
  --initial            Run the update script one time before hooking into the
                       docker event stream.
  -v, --verbosity LVL  Either CRITICAL, ERROR, WARNING, INFO or DEBUG
  --help               Show this message and exit.

Running it in a shell:

sudo docker_hosts_update

Systemd init script to run it as a service:

Description=Updates /etc/hosts based on running docker containers.

Restart=on-failure # or always, on-abort, etc


Future features / ideas:

  • configurable host name format
  • whitelist / blacklist
  • deb package
  • user desktop notifications
  • ui to toggle whitelist/blacklist
  • completely different package docker-event-template (like consul-template with a better templating language)
  • another os service: hostctl, just for managing the hosts file (with unix socket to communicate over).
  • service security