Reports currently running docker containers to etcd
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Docker service reporter

This is a small python script that will discover all running docker containers and store information about them in etcd.


Having service details in shared storage such as etcd allows other processes to discover services, or automate configuration or administration tasks (such as configuring reverse proxies).


The container requires access to the docker API, so you need to volume mount the docker socket:

docker run -d --name service-reporter \
              --restart always \
              -v /var/run/docker.sock:/var/run/docker.sock \ 
              csmith/service-reporter:latest \

The following command line arguments are available:

  --etcd-host (default: etcd) hostname where ectd is running
  --etcd-port (default: 2379) port to connect to ectd on
  --etcd-prefix (default: /docker) prefix to write keys to
  --name (default: unknown) name of the host running docker

The script will update etcd as soon as it launches, and then monitor for docker events and apply the relevant updates.


The script stores values relating to containers, labels, hosts and networks in etcd:

/docker/containers/{name1}/host = ""
                          /image = "ubuntu:xenial"
                          /labels/service = "foo"
                          /labels/org.example.some-label = "bar"
                          /net/addr/{network1} = ""
                                   /{network2} = ""
                              /ports/tcp/{container_port1} = {host_port}
                                        /{container_port2} = 0 # Not exposed

       /hosts/{host_1}/{container_name_1} = {container_name_1}

       /labels/{label_1}/{container_name_1} = "foo"
                        /{container_name_2} = "bar"

       /networks/{network1}/{container_name_1} = ""
                           /{container_name_2} = ""

There is also a special node at /docker/_updated which is updated with the current unix timestamp after an update has finished. This may be useful to watch in scripts that need to trigger after container changes (listening to the containers would trigger as soon as the first child node is written, so is probably not useful in most situations).

Current known issues

  • The docker node is deleted when the script starts, so you can't run multiple copies on multiple hosts