@@ -36,10 +36,10 @@ Linux/OSX binaries for release [0.9.0](https://github.com/nginx-proxy/docker-gen
3636
3737Download the version you need, untar, and install to your PATH.
3838
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
4343```
4444
4545#### Bundled Container Install
@@ -62,24 +62,24 @@ this to prevent having the docker socket bound to a publicly exposed container s
6262
6363Start nginx with a shared volume:
6464
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
6767```
6868
6969Fetch 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 \
7474 -v /var/run/docker.sock:/tmp/docker.sock:rw \
7575 -v /tmp/templates:/etc/docker-gen/templates \
7676 -t nginxproxy/docker-gen -notify-sighup nginx -watch -only-exposed /etc/docker-gen/templates/nginx.tmpl /etc/nginx/conf.d/default.conf
7777```
7878
7979Start a container, taking note of any Environment variables a container expects. See the top of a template for details.
8080
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 ...
8383```
8484
8585===
@@ -152,40 +152,40 @@ Using the -config flag from above you can tell docker-gen to use the specified c
152152An example configuration file, ** docker-gen.cfg** can be found in the examples folder.
153153
154154#### Configuration File Syntax
155- ```
155+ ``` ini
156156[[config] ]
157- Starts a configuration section
157+ # Starts a configuration section
158158
159159dest = " 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
161161
162162notifycmd = " /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)
164164
165165onlyexposed = true
166- only include containers with exposed ports
166+ # only include containers with exposed ports
167167
168168template = " /path/to/a/template/file.tmpl"
169- path to a template to generate
169+ # path to a template to generate
170170
171171watch = true
172- watch for container changes
172+ # watch for container changes
173173
174174wait = " 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
176176
177177
178178[config.NotifyContainers]
179- Starts a notify container section
179+ # Starts a notify container section
180180
181181containername = 1
182- container name followed by the signal to send
182+ # container name followed by the signal to send
183183
184184container_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
186186```
187187Putting it all together here is an example configuration file.
188- ```
188+ ``` ini
189189[[config] ]
190190template = " /etc/nginx/nginx.conf.tmpl"
191191dest = " /etc/nginx/sites-available/default"
@@ -221,6 +221,7 @@ Within the templates, the object emitted by docker-gen will be a structure consi
221221``` go
222222type RuntimeContainer struct {
223223 ID string
224+ Created time.Time
224225 Addresses []Address
225226 Networks []Network
226227 Gateway string
@@ -311,7 +312,6 @@ type Docker struct {
311312}
312313
313314// Host environment variables accessible from root in templates as .Env
314-
315315```
316316
317317For 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:
419419
420420Start nginx-proxy:
421421
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
424424```
425425
426426Then start containers with a VIRTUAL_HOST (and the VIRTUAL_PORT if more than one port is exposed) env variable:
427427
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 ...
430430```
431431
432432If you wanted to run docker-gen directly on the host, you could do it with:
433433
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
436436```
437437
438438#### Fluentd Log Management
439439
440440This template generate a fluentd.conf file used by fluentd. It would then ship log files off
441441the host.
442442
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
445445```
446446
447447#### Service Discovery in Etcd
@@ -450,8 +450,8 @@ $ docker-gen -watch -notify "restart fluentd" templates/fluentd.tmpl /etc/fluent
450450This template is an example of generating a script that is then executed. This template generates
451451a python script that is then executed which register containers in Etcd using its HTTP API.
452452
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
455455```
456456
457457
@@ -463,11 +463,11 @@ This means that at least `go 1.11` is required.
463463For ` go 1.11 ` and ` go 1.12 ` it is additionally required to manually enable support by setting ` GO111MODULE=on ` .
464464For later versions, this is not required.
465465
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
471471```
472472
473473### TODO
0 commit comments