Skip to content

Commit d3962a7

Browse files
committed
docs: update README and CLI usage
1 parent aa0b789 commit d3962a7

File tree

2 files changed

+51
-37
lines changed

2 files changed

+51
-37
lines changed

README.md

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -87,72 +87,75 @@ Usage: docker-gen [options] template [dest]
8787
Generate files from docker container meta-data
8888
8989
Options:
90-
-config value
91-
config files with template directives. Config files will be merged if this option is specified multiple times. (default [])
90+
-config path
91+
config files with template directives.
92+
Config files will be merged if this option is specified multiple times. (default [])
93+
-container-filter key=value
94+
container filter for inclusion by docker-gen.
95+
You can pass this option multiple times to combine filters with AND.
96+
https://docs.docker.com/engine/reference/commandline/ps/#filter
9297
-endpoint string
9398
docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock
94-
-event-filter value
99+
-event-filter key=value
95100
additional filter for event watched by docker-gen (e.g -event-filter event=connect -event-filter event=disconnect).
96101
You can pass this option multiple times to combine filters.
97102
By default docker-gen listen for container events start, stop, die and health_status.
98103
https://docs.docker.com/engine/reference/commandline/events/#filtering-events
104+
-include-stopped
105+
include stopped containers.
106+
Bypassed when providing a container status filter (-container-filter status=foo).
99107
-interval int
100108
notify command interval (secs)
101109
-keep-blank-lines
102110
keep blank lines in the output file
103111
-notify restart xyz
104112
run command after template is regenerated (e.g restart xyz)
105-
-notify-output
106-
log the output(stdout/stderr) of notify command
107-
-notify-sighup container-ID
108-
send HUP signal to container.
109-
Equivalent to 'docker kill -s HUP container-ID', or `-notify-container container-ID -notify-signal 1`.
110-
You can pass this option multiple times to send HUP to multiple containers.
111113
-notify-container container-ID
112114
send -notify-signal signal (defaults to 1 / HUP) to container.
113115
You can pass this option multiple times to notify multiple containers.
114116
-notify-filter key=value
115117
container filter for notification (e.g -notify-filter name=foo).
116118
You can pass this option multiple times to combine filters with AND.
117119
https://docs.docker.com/engine/reference/commandline/ps/#filter
120+
-notify-output
121+
log the output(stdout/stderr) of notify command
122+
-notify-sighup container-ID
123+
send HUP signal to container.
124+
Equivalent to 'docker kill -s HUP container-ID', or `-notify-container container-ID -notify-signal 1`.
125+
You can pass this option multiple times to send HUP to multiple containers.
118126
-notify-signal signal
119127
signal to send to the -notify-container and -notify-filter. -1 to call docker restart. Defaults to 1 aka. HUP.
120128
All available signals available on the dockerclient
121129
https://github.com/fsouza/go-dockerclient/blob/main/signal.go
122130
-only-exposed
123-
only include containers with exposed ports
131+
only include containers with exposed ports.
132+
Bypassed when using the exposed filter with (-container-filter exposed=foo).
124133
-only-published
125-
only include containers with published ports (implies -only-exposed)
126-
-include-stopped
127-
include stopped containers
128-
-container-filter
129-
container filter for inclusion by docker-gen (e.g -container-filter status=running).
130-
Using this option bypass the -include-stopped option and set it to true.
131-
You can pass this option multiple times to combine filters with AND.
132-
https://docs.docker.com/engine/reference/commandline/ps/#filter
134+
only include containers with published ports (implies -only-exposed).
135+
Bypassed when providing a container published filter (-container-filter published=foo).
133136
-tlscacert string
134-
path to TLS CA certificate file (default "~/.docker/machine/machines/default/ca.pem")
137+
path to TLS CA certificate file (default "~/.docker/ca.pem")
135138
-tlscert string
136-
path to TLS client certificate file (default "~/.docker/machine/machines/default/cert.pem")
139+
path to TLS client certificate file (default "~/.docker/cert.pem")
137140
-tlskey string
138-
path to TLS client key file (default "~/.docker/machine/machines/default/key.pem")
141+
path to TLS client key file (default "~/.docker/key.pem")
139142
-tlsverify
140-
verify docker daemon's TLS certicate (default true)
143+
verify docker daemon's TLS certicate
141144
-version
142145
show version
146+
-wait string
147+
minimum and maximum durations to wait (e.g. "500ms:2s") before triggering generate
143148
-watch
144149
watch for container changes
145-
-wait
146-
minimum (and/or maximum) duration to wait after each container change before triggering
147150
148151
Arguments:
149152
template - path to a template to generate
150-
dest - path to write the template. If not specfied, STDOUT is used
153+
dest - path to write the template to. If not specfied, STDOUT is used
151154
152155
Environment Variables:
153156
DOCKER_HOST - default value for -endpoint
154-
DOCKER_CERT_PATH - directory path containing key.pem, cert.pm and ca.pem
155-
DOCKER_TLS_VERIFY - enable client TLS verification]
157+
DOCKER_CERT_PATH - directory path containing key.pem, cert.pem and ca.pem
158+
DOCKER_TLS_VERIFY - enable client TLS verification
156159
```
157160

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

cmd/docker-gen/main.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ Options:`)
7979
println(`
8080
Arguments:
8181
template - path to a template to generate
82-
dest - path to a write the template. If not specfied, STDOUT is used`)
82+
dest - path to write the template to. If not specfied, STDOUT is used`)
8383

8484
println(`
8585
Environment Variables:
@@ -99,23 +99,35 @@ func loadConfig(file string) error {
9999
}
100100

101101
func initFlags() {
102-
103102
certPath := filepath.Join(os.Getenv("DOCKER_CERT_PATH"))
104103
if certPath == "" {
105104
certPath = filepath.Join(os.Getenv("HOME"), ".docker")
106105
}
106+
107107
flag.BoolVar(&version, "version", false, "show version")
108+
109+
// General configuration options
108110
flag.BoolVar(&watch, "watch", false, "watch for container changes")
109111
flag.StringVar(&wait, "wait", "", "minimum and maximum durations to wait (e.g. \"500ms:2s\") before triggering generate")
110-
flag.BoolVar(&onlyExposed, "only-exposed", false, "only include containers with exposed ports")
112+
flag.Var(&configFiles, "config", "config files with template directives. Config files will be merged if this option is specified multiple times.")
113+
flag.BoolVar(&keepBlankLines, "keep-blank-lines", false, "keep blank lines in the output file")
111114

115+
// Containers filtering options
116+
flag.BoolVar(&onlyExposed, "only-exposed", false,
117+
"only include containers with exposed ports. Bypassed when providing a container exposed filter (-container-filter exposed=foo).")
112118
flag.BoolVar(&onlyPublished, "only-published", false,
113-
"only include containers with published ports (implies -only-exposed)")
114-
flag.BoolVar(&includeStopped, "include-stopped", false, "include stopped containers")
119+
"only include containers with published ports (implies -only-exposed). Bypassed when providing a container published filter (-container-filter published=foo).")
120+
flag.BoolVar(&includeStopped, "include-stopped", false,
121+
"include stopped containers. Bypassed when providing a container status filter (-container-filter status=foo).")
115122
flag.Var(&containerFilter, "container-filter",
116-
"container filter for inclusion by docker-gen. Using this option bypass the -include-stopped option and set it to true. You can pass this option multiple times to combine filters with AND. https://docs.docker.com/engine/reference/commandline/ps/#filter")
117-
flag.BoolVar(&notifyOutput, "notify-output", false, "log the output(stdout/stderr) of notify command")
123+
"container filter for inclusion by docker-gen. You can pass this option multiple times to combine filters with AND. https://docs.docker.com/engine/reference/commandline/ps/#filter")
124+
125+
// Command notification options
118126
flag.StringVar(&notifyCmd, "notify", "", "run command after template is regenerated (e.g `restart xyz`)")
127+
flag.BoolVar(&notifyOutput, "notify-output", false, "log the output(stdout/stderr) of notify command")
128+
flag.IntVar(&interval, "interval", 0, "notify command interval (secs)")
129+
130+
// Containers notification options
119131
flag.Var(&sighupContainerID, "notify-sighup",
120132
"send HUP signal to container. Equivalent to docker kill -s HUP `container-ID`. You can pass this option multiple times to send HUP to multiple containers.")
121133
flag.Var(&notifyContainerID, "notify-container",
@@ -124,9 +136,8 @@ func initFlags() {
124136
"container filter for notification (e.g -notify-filter name=foo). You can pass this option multiple times to combine filters with AND. https://docs.docker.com/engine/reference/commandline/ps/#filter")
125137
flag.IntVar(&notifyContainerSignal, "notify-signal", int(docker.SIGHUP),
126138
"signal to send to the notify-container and notify-filter. Defaults to SIGHUP")
127-
flag.Var(&configFiles, "config", "config files with template directives. Config files will be merged if this option is specified multiple times.")
128-
flag.IntVar(&interval, "interval", 0, "notify command interval (secs)")
129-
flag.BoolVar(&keepBlankLines, "keep-blank-lines", false, "keep blank lines in the output file")
139+
140+
// Docker API endpoint configuration options
130141
flag.StringVar(&endpoint, "endpoint", "", "docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock")
131142
flag.StringVar(&tlsCert, "tlscert", filepath.Join(certPath, "cert.pem"), "path to TLS client certificate file")
132143
flag.StringVar(&tlsKey, "tlskey", filepath.Join(certPath, "key.pem"), "path to TLS client key file")

0 commit comments

Comments
 (0)