|
@@ -0,0 +1,55 @@
|
|
1
|
+# Docker service reporter
|
|
2
|
+
|
|
3
|
+This is a small python script that will discover all running
|
|
4
|
+docker containers and store information about them in etcd.
|
|
5
|
+
|
|
6
|
+## Why?
|
|
7
|
+
|
|
8
|
+Having service details in shared storage such as etcd allows
|
|
9
|
+other processes to discover services, or automate configuration
|
|
10
|
+or administration tasks (such as configuring reverse proxies).
|
|
11
|
+
|
|
12
|
+## Usage
|
|
13
|
+
|
|
14
|
+The container requires access to the docker API, so you need
|
|
15
|
+to volume mount the docker socket:
|
|
16
|
+
|
|
17
|
+```bash
|
|
18
|
+docker run -d --name service-reporter \
|
|
19
|
+ --restart always \
|
|
20
|
+ -v /var/run/docker.sock:/var/run/docker.sock \
|
|
21
|
+ csmith/service-reporter:latest
|
|
22
|
+```
|
|
23
|
+
|
|
24
|
+## Schema
|
|
25
|
+
|
|
26
|
+The script stores values relating to containers, labels, and
|
|
27
|
+networks in etcd:
|
|
28
|
+
|
|
29
|
+```
|
|
30
|
+/docker/containers/{name}/image = "ubuntu:xenial"
|
|
31
|
+ /labels/service = "foo"
|
|
32
|
+ /labels/org.example.some-label = "bar"
|
|
33
|
+ /net/addr/{network1} = "172.1.2.3"
|
|
34
|
+ /{network2} = "172.0.2.3"
|
|
35
|
+ /ports/tcp/{container_port1} = {host_port}
|
|
36
|
+ /{container_port2} = 0 # Not exposed
|
|
37
|
+ /udp/...
|
|
38
|
+
|
|
39
|
+/docker/labels/{label_1}/{container_name_1} = "foo"
|
|
40
|
+ /{container_name_2} = "bar"
|
|
41
|
+ /{label_2}/...
|
|
42
|
+
|
|
43
|
+/docker/networks/{network1}/{container_name_1} = "172.1.2.3"
|
|
44
|
+ /{container_name_2} = "172.0.2.3"
|
|
45
|
+ /{network2}/...
|
|
46
|
+```
|
|
47
|
+
|
|
48
|
+## Current known issues
|
|
49
|
+
|
|
50
|
+* The docker node is deleted when the script starts, so you can't run multiple
|
|
51
|
+ copies on multiple hosts
|
|
52
|
+* The script updates once and exits, instead of listening for events
|
|
53
|
+* There's no way to get notified when the script has finished, rather than
|
|
54
|
+ mid-update
|
|
55
|
+
|