Skip to content

Commit 39f07e0

Browse files
committed
Update documents to include information about using a configuration file. Also update the formating on the usage section to allow the discriptions to wrap. Before wrap it was necessary to scroll left and right to read them.
1 parent 43102b3 commit 39f07e0

File tree

1 file changed

+90
-35
lines changed

1 file changed

+90
-35
lines changed

README.md

Lines changed: 90 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -77,52 +77,107 @@ $ docker run -d --name nginx-gen --volumes-from nginx \
7777
### Usage
7878
```
7979
$ docker-gen
80-
Usage: docker-gen [options] template [dest]
80+
```
81+
**Usage: docker-gen [options] template [dest]**
8182

8283
Generate files from docker container meta-data
8384

8485
Options:
85-
-config value
86-
config files with template directives. Config files will be merged if this option is specified multiple times. (default [])
87-
-endpoint string
88-
docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock
89-
-interval int
90-
notify command interval (secs)
91-
-keep-blank-lines
92-
keep blank lines in the output file
93-
-notify restart xyz
94-
run command after template is regenerated (e.g restart xyz)
95-
-notify-sighup docker kill -s HUP container-ID
96-
send HUP signal to container. Equivalent to docker kill -s HUP container-ID
97-
-only-exposed
98-
only include containers with exposed ports
99-
-only-published
100-
only include containers with published ports (implies -only-exposed)
101-
-tlscacert string
102-
path to TLS CA certificate file (default "/Users/jason/.docker/machine/machines/default/ca.pem")
103-
-tlscert string
104-
path to TLS client certificate file (default "/Users/jason/.docker/machine/machines/default/cert.pem")
105-
-tlskey string
106-
path to TLS client key file (default "/Users/jason/.docker/machine/machines/default/key.pem")
107-
-tlsverify
108-
verify docker daemon's TLS certicate (default true)
109-
-version
110-
show version
111-
-watch
112-
watch for container changes
86+
   -config value
87+
       config files with template directives. Config files will be merged if this option is specified multiple times. (default [])
88+
   -endpoint string
89+
       docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock
90+
   -interval int
91+
       notify command interval (secs)
92+
   -keep-blank-lines
93+
       keep blank lines in the output file
94+
   -notify restart xyz
95+
       run command after template is regenerated (e.g restart xyz)
96+
   -notify-sighup docker kill -s HUP container-ID
97+
       send HUP signal to container. Equivalent to docker kill -s HUP container-ID
98+
   -only-exposed
99+
       only include containers with exposed ports
100+
   -only-published
101+
       only include containers with published ports (implies -only-exposed)
102+
   -tlscacert string
103+
       path to TLS CA certificate file (default "/Users/jason/.docker/machine/machines/default/ca.pem")
104+
   -tlscert string
105+
       path to TLS client certificate file (default "/Users/jason/.docker/machine/machines/default/cert.pem")
106+
   -tlskey string
107+
       path to TLS client key file (default "/Users/jason/.docker/machine/machines/default/key.pem")
108+
   -tlsverify
109+
       verify docker daemon's TLS certicate (default true)
110+
   -version
111+
       show version
112+
   -watch
113+
       watch for container changes
113114

114115
Arguments:
115-
template - path to a template to generate
116-
dest - path to a write the template. If not specfied, STDOUT is used
116+
   template - path to a template to generate
117+
   dest - path to a write the template. If not specfied, STDOUT is used
117118

118119
Environment Variables:
119-
DOCKER_HOST - default value for -endpoint
120-
DOCKER_CERT_PATH - directory path containing key.pem, cert.pm and ca.pem
121-
DOCKER_TLS_VERIFY - enable client TLS verification]
122-
```
120+
   DOCKER_HOST - default value for -endpoint
121+
   DOCKER_CERT_PATH - directory path containing key.pem, cert.pm and ca.pem
122+
   DOCKER_TLS_VERIFY - enable client TLS verification]
123+
123124

124125
If no `<dest>` file is specified, the output is sent to stdout. Mainly useful for debugging.
125126

127+
### Configuration file
128+
129+
Using the -config flag from above you can tell docker-gen to use the specified config file instead of command-line options. Multiple templates can be defined and they will be executed in the order that they appear in the config file.
130+
131+
An example configuration file, **docker-gen.cfg** can be found in the examples folder.
132+
133+
#### Configuration File Syntax
134+
135+
***[[config]]***
136+
&nbsp;&nbsp;&nbsp;&nbsp;Starts a configuration section
137+
138+
**dest = "path/to/a/file"**
139+
&nbsp;&nbsp;&nbsp;&nbsp;path to a write the template. If not specfied, STDOUT is used
140+
**notifycmd = "/etc/init.d/foo reload"**
141+
&nbsp;&nbsp;&nbsp;&nbsp;run command after template is regenerated (e.g restart xyz)
142+
**onlyexposed = true**
143+
&nbsp;&nbsp;&nbsp;&nbsp;only include containers with exposed ports
144+
**template = "/path/to/a/template/file.tmpl"**
145+
&nbsp;&nbsp;&nbsp;&nbsp;path to a template to generate
146+
**watch = true**
147+
&nbsp;&nbsp;&nbsp;&nbsp;watch for container changes
148+
149+
150+
***[config.NotifyContainers]***
151+
&nbsp;&nbsp;&nbsp;&nbsp;Starts a notify container section
152+
153+
**containername = 1**
154+
&nbsp;&nbsp;&nbsp;&nbsp;container name followed by the signal to send
155+
**container_id = 1**
156+
&nbsp;&nbsp;&nbsp;&nbsp;or the container id can be used followed by the signal to send
157+
158+
Putting it all together here is an example configuration file.
159+
```
160+
[[config]]
161+
template = "/etc/nginx/nginx.conf.tmpl"
162+
dest = "/etc/nginx/sites-available/default"
163+
onlyexposed = true
164+
notifycmd = "/etc/init.d/nginx reload"
165+
166+
[[config]]
167+
template = "/etc/logrotate.conf.tmpl"
168+
dest = "/etc/logrotate.d/docker"
169+
watch = true
170+
171+
[[config]]
172+
template = "/etc/docker-gen/templates/nginx.tmpl"
173+
dest = "/etc/nginx/conf.d/default.conf"
174+
watch = true
175+
176+
[config.NotifyContainers]
177+
nginx = 1 # 1 is a signal number to be sent; here SIGINT
178+
e75a60548dc9 = 1 # a key can be either container name (nginx) or ID
179+
```
180+
126181
===
127182

128183
### Templating

0 commit comments

Comments
 (0)