Skip to content

Commit b8b39af

Browse files
committed
docs: update README and CLI usage
1 parent 6e61ca7 commit b8b39af

File tree

2 files changed

+50
-36
lines changed

2 files changed

+50
-36
lines changed

README.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -87,67 +87,70 @@ 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
99+
-include-stopped
100+
include stopped containers.
101+
Bypassed when providing a container status filter (-container-filter status=foo).
94102
-interval int
95103
notify command interval (secs)
96104
-keep-blank-lines
97105
keep blank lines in the output file
98106
-notify restart xyz
99107
run command after template is regenerated (e.g restart xyz)
100-
-notify-output
101-
log the output(stdout/stderr) of notify command
102-
-notify-sighup container-ID
103-
send HUP signal to container.
104-
Equivalent to 'docker kill -s HUP container-ID', or `-notify-container container-ID -notify-signal 1`.
105-
You can pass this option multiple times to send HUP to multiple containers.
106108
-notify-container container-ID
107109
send -notify-signal signal (defaults to 1 / HUP) to container.
108110
You can pass this option multiple times to notify multiple containers.
109111
-notify-filter key=value
110112
container filter for notification (e.g -notify-filter name=foo).
111113
You can pass this option multiple times to combine filters with AND.
112114
https://docs.docker.com/engine/reference/commandline/ps/#filter
115+
-notify-output
116+
log the output(stdout/stderr) of notify command
117+
-notify-sighup container-ID
118+
send HUP signal to container.
119+
Equivalent to 'docker kill -s HUP container-ID', or `-notify-container container-ID -notify-signal 1`.
120+
You can pass this option multiple times to send HUP to multiple containers.
113121
-notify-signal signal
114122
signal to send to the -notify-container and -notify-filter. -1 to call docker restart. Defaults to 1 aka. HUP.
115123
All available signals available on the dockerclient
116124
https://github.com/fsouza/go-dockerclient/blob/main/signal.go
117125
-only-exposed
118-
only include containers with exposed ports
126+
only include containers with exposed ports.
127+
Bypassed when using the exposed filter with (-container-filter exposed=foo).
119128
-only-published
120-
only include containers with published ports (implies -only-exposed)
121-
-include-stopped
122-
include stopped containers
123-
-container-filter
124-
container filter for inclusion by docker-gen (e.g -container-filter status=running).
125-
Using this option bypass the -include-stopped option and set it to true.
126-
You can pass this option multiple times to combine filters with AND.
127-
https://docs.docker.com/engine/reference/commandline/ps/#filter
129+
only include containers with published ports (implies -only-exposed).
130+
Bypassed when providing a container published filter (-container-filter published=foo).
128131
-tlscacert string
129-
path to TLS CA certificate file (default "~/.docker/machine/machines/default/ca.pem")
132+
path to TLS CA certificate file (default "~/.docker/ca.pem")
130133
-tlscert string
131-
path to TLS client certificate file (default "~/.docker/machine/machines/default/cert.pem")
134+
path to TLS client certificate file (default "~/.docker/cert.pem")
132135
-tlskey string
133-
path to TLS client key file (default "~/.docker/machine/machines/default/key.pem")
136+
path to TLS client key file (default "~/.docker/key.pem")
134137
-tlsverify
135-
verify docker daemon's TLS certicate (default true)
138+
verify docker daemon's TLS certicate
136139
-version
137140
show version
141+
-wait string
142+
minimum and maximum durations to wait (e.g. "500ms:2s") before triggering generate
138143
-watch
139144
watch for container changes
140-
-wait
141-
minimum (and/or maximum) duration to wait after each container change before triggering
142145
143146
Arguments:
144147
template - path to a template to generate
145-
dest - path to write the template. If not specfied, STDOUT is used
148+
dest - path to write the template to. If not specfied, STDOUT is used
146149
147150
Environment Variables:
148151
DOCKER_HOST - default value for -endpoint
149-
DOCKER_CERT_PATH - directory path containing key.pem, cert.pm and ca.pem
150-
DOCKER_TLS_VERIFY - enable client TLS verification]
152+
DOCKER_CERT_PATH - directory path containing key.pem, cert.pem and ca.pem
153+
DOCKER_TLS_VERIFY - enable client TLS verification
151154
```
152155

153156
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
@@ -78,7 +78,7 @@ Options:`)
7878
println(`
7979
Arguments:
8080
template - path to a template to generate
81-
dest - path to a write the template. If not specfied, STDOUT is used`)
81+
dest - path to write the template to. If not specfied, STDOUT is used`)
8282

8383
println(`
8484
Environment Variables:
@@ -98,23 +98,35 @@ func loadConfig(file string) error {
9898
}
9999

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

114+
// Containers filtering options
115+
flag.BoolVar(&onlyExposed, "only-exposed", false,
116+
"only include containers with exposed ports. Bypassed when providing a container exposed filter (-container-filter exposed=foo).")
111117
flag.BoolVar(&onlyPublished, "only-published", false,
112-
"only include containers with published ports (implies -only-exposed)")
113-
flag.BoolVar(&includeStopped, "include-stopped", false, "include stopped containers")
118+
"only include containers with published ports (implies -only-exposed). Bypassed when providing a container published filter (-container-filter published=foo).")
119+
flag.BoolVar(&includeStopped, "include-stopped", false,
120+
"include stopped containers. Bypassed when providing a container status filter (-container-filter status=foo).")
114121
flag.Var(&containerFilter, "container-filter",
115-
"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")
116-
flag.BoolVar(&notifyOutput, "notify-output", false, "log the output(stdout/stderr) of notify command")
122+
"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")
123+
124+
// Command notification options
117125
flag.StringVar(&notifyCmd, "notify", "", "run command after template is regenerated (e.g `restart xyz`)")
126+
flag.BoolVar(&notifyOutput, "notify-output", false, "log the output(stdout/stderr) of notify command")
127+
flag.IntVar(&interval, "interval", 0, "notify command interval (secs)")
128+
129+
// Containers notification options
118130
flag.Var(&sighupContainerID, "notify-sighup",
119131
"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.")
120132
flag.Var(&notifyContainerID, "notify-container",
@@ -123,9 +135,8 @@ func initFlags() {
123135
"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")
124136
flag.IntVar(&notifyContainerSignal, "notify-signal", int(docker.SIGHUP),
125137
"signal to send to the notify-container and notify-filter. Defaults to SIGHUP")
126-
flag.Var(&configFiles, "config", "config files with template directives. Config files will be merged if this option is specified multiple times.")
127-
flag.IntVar(&interval, "interval", 0, "notify command interval (secs)")
128-
flag.BoolVar(&keepBlankLines, "keep-blank-lines", false, "keep blank lines in the output file")
138+
139+
// Docker API endpoint configuration options
129140
flag.StringVar(&endpoint, "endpoint", "", "docker api endpoint (tcp|unix://..). Default unix:///var/run/docker.sock")
130141
flag.StringVar(&tlsCert, "tlscert", filepath.Join(certPath, "cert.pem"), "path to TLS client certificate file")
131142
flag.StringVar(&tlsKey, "tlskey", filepath.Join(certPath, "key.pem"), "path to TLS client key file")

0 commit comments

Comments
 (0)