@@ -36,10 +36,10 @@ Linux/OSX binaries for release [0.9.0](https://github.com/nginx-proxy/docker-gen
36
36
37
37
Download the version you need, untar, and install to your PATH.
38
38
39
- ```
40
- $ wget https://github.com/nginx-proxy/docker-gen/releases/download/0.9.0/docker-gen-linux-amd64-0.9.0.tar.gz
41
- $ tar xvzf docker-gen-linux-amd64-0.9.0.tar.gz
42
- $ ./docker-gen
39
+ ``` console
40
+ wget https://github.com/nginx-proxy/docker-gen/releases/download/0.9.0/docker-gen-linux-amd64-0.9.0.tar.gz
41
+ tar xvzf docker-gen-linux-amd64-0.9.0.tar.gz
42
+ ./docker-gen
43
43
```
44
44
45
45
#### Bundled Container Install
@@ -62,24 +62,24 @@ this to prevent having the docker socket bound to a publicly exposed container s
62
62
63
63
Start nginx with a shared volume:
64
64
65
- ```
66
- $ docker run -d -p 80:80 --name nginx -v /tmp/nginx:/etc/nginx/conf.d -t nginx
65
+ ``` console
66
+ docker run -d -p 80:80 --name nginx -v /tmp/nginx:/etc/nginx/conf.d -t nginx
67
67
```
68
68
69
69
Fetch the template and start the docker-gen container with the shared volume:
70
- ```
71
- $ mkdir -p /tmp/templates && cd /tmp/templates
72
- $ curl -o nginx.tmpl https://raw.githubusercontent.com/nginx-proxy/docker-gen/main/templates/nginx.tmpl
73
- $ docker run -d --name nginx-gen --volumes-from nginx \
70
+ ``` console
71
+ mkdir -p /tmp/templates && cd /tmp/templates
72
+ curl -o nginx.tmpl https://raw.githubusercontent.com/nginx-proxy/docker-gen/main/templates/nginx.tmpl
73
+ docker run -d --name nginx-gen --volumes-from nginx \
74
74
-v /var/run/docker.sock:/tmp/docker.sock:rw \
75
75
-v /tmp/templates:/etc/docker-gen/templates \
76
76
-t nginxproxy/docker-gen -notify-sighup nginx -watch -only-exposed /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
77
77
```
78
78
79
79
Start a container, taking note of any Environment variables a container expects. See the top of a template for details.
80
80
81
- ```
82
- $ docker run --env VIRTUAL_HOST='example.com' --env VIRTUAL_PORT=80 ...
81
+ ``` console
82
+ docker run --env VIRTUAL_HOST='example.com' --env VIRTUAL_PORT=80 ...
83
83
```
84
84
85
85
===
@@ -152,40 +152,40 @@ Using the -config flag from above you can tell docker-gen to use the specified c
152
152
An example configuration file, ** docker-gen.cfg** can be found in the examples folder.
153
153
154
154
#### Configuration File Syntax
155
- ```
155
+ ``` ini
156
156
[[config] ]
157
- Starts a configuration section
157
+ # Starts a configuration section
158
158
159
159
dest = " path/to/a/file"
160
- path to write the template. If not specfied, STDOUT is used
160
+ # path to write the template. If not specfied, STDOUT is used
161
161
162
162
notifycmd = " /etc/init.d/foo reload"
163
- run command after template is regenerated (e.g restart xyz)
163
+ # run command after template is regenerated (e.g restart xyz)
164
164
165
165
onlyexposed = true
166
- only include containers with exposed ports
166
+ # only include containers with exposed ports
167
167
168
168
template = " /path/to/a/template/file.tmpl"
169
- path to a template to generate
169
+ # path to a template to generate
170
170
171
171
watch = true
172
- watch for container changes
172
+ # watch for container changes
173
173
174
174
wait = " 500ms:2s"
175
- debounce changes with a min:max duration. Only applicable if watch = true
175
+ # debounce changes with a min:max duration. Only applicable if watch = true
176
176
177
177
178
178
[config.NotifyContainers]
179
- Starts a notify container section
179
+ # Starts a notify container section
180
180
181
181
containername = 1
182
- container name followed by the signal to send
182
+ # container name followed by the signal to send
183
183
184
184
container_id = 1
185
- or the container id can be used followed by the signal to send
185
+ # or the container id can be used followed by the signal to send
186
186
```
187
187
Putting it all together here is an example configuration file.
188
- ```
188
+ ``` ini
189
189
[[config] ]
190
190
template = " /etc/nginx/nginx.conf.tmpl"
191
191
dest = " /etc/nginx/sites-available/default"
@@ -221,6 +221,7 @@ Within the templates, the object emitted by docker-gen will be a structure consi
221
221
``` go
222
222
type RuntimeContainer struct {
223
223
ID string
224
+ Created time.Time
224
225
Addresses []Address
225
226
Networks []Network
226
227
Gateway string
@@ -311,7 +312,6 @@ type Docker struct {
311
312
}
312
313
313
314
// Host environment variables accessible from root in templates as .Env
314
-
315
315
```
316
316
317
317
For example, this is a JSON version of an emitted RuntimeContainer struct:
@@ -419,29 +419,29 @@ For example, this is a JSON version of an emitted RuntimeContainer struct:
419
419
420
420
Start nginx-proxy:
421
421
422
- ```
423
- $ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock -t nginxproxy/nginx-proxy
422
+ ``` console
423
+ docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock -t nginxproxy/nginx-proxy
424
424
```
425
425
426
426
Then start containers with a VIRTUAL_HOST (and the VIRTUAL_PORT if more than one port is exposed) env variable:
427
427
428
- ```
429
- $ docker run -e VIRTUAL_HOST=foo.bar.com -e VIRTUAL_PORT=80 -t ...
428
+ ``` console
429
+ docker run -e VIRTUAL_HOST=foo.bar.com -e VIRTUAL_PORT=80 -t ...
430
430
```
431
431
432
432
If you wanted to run docker-gen directly on the host, you could do it with:
433
433
434
- ```
435
- $ docker-gen -only-published -watch -notify "/etc/init.d/nginx reload" templates/nginx.tmpl /etc/nginx/sites-enabled/default
434
+ ``` console
435
+ docker-gen -only-published -watch -notify "/etc/init.d/nginx reload" templates/nginx.tmpl /etc/nginx/sites-enabled/default
436
436
```
437
437
438
438
#### Fluentd Log Management
439
439
440
440
This template generate a fluentd.conf file used by fluentd. It would then ship log files off
441
441
the host.
442
442
443
- ```
444
- $ docker-gen -watch -notify "restart fluentd" templates/fluentd.tmpl /etc/fluent/fluent.conf
443
+ ``` console
444
+ docker-gen -watch -notify "restart fluentd" templates/fluentd.tmpl /etc/fluent/fluent.conf
445
445
```
446
446
447
447
#### Service Discovery in Etcd
@@ -450,8 +450,8 @@ $ docker-gen -watch -notify "restart fluentd" templates/fluentd.tmpl /etc/fluent
450
450
This template is an example of generating a script that is then executed. This template generates
451
451
a python script that is then executed which register containers in Etcd using its HTTP API.
452
452
453
- ```
454
- $ docker-gen -notify "/bin/bash /tmp/etcd.sh" -interval 10 templates/etcd.tmpl /tmp/etcd.sh
453
+ ``` console
454
+ docker-gen -notify "/bin/bash /tmp/etcd.sh" -interval 10 templates/etcd.tmpl /tmp/etcd.sh
455
455
```
456
456
457
457
@@ -463,11 +463,11 @@ This means that at least `go 1.11` is required.
463
463
For ` go 1.11 ` and ` go 1.12 ` it is additionally required to manually enable support by setting ` GO111MODULE=on ` .
464
464
For later versions, this is not required.
465
465
466
- ```
467
- $ git clone <your fork>
468
- $ cd <your fork>
469
- $ make get-deps
470
- $ make
466
+ ``` console
467
+ git clone <your fork>
468
+ cd <your fork>
469
+ make get-deps
470
+ make
471
471
```
472
472
473
473
### TODO
0 commit comments