Skip to content

Commit e05feb8

Browse files
committed
fix: -container-filter should override the env var
1 parent 615f63a commit e05feb8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Environment Variables:
157157
DOCKER_CERT_PATH - directory path containing key.pem, cert.pem and ca.pem
158158
DOCKER_TLS_VERIFY - enable client TLS verification
159159
DOCKER_CONTAINER_FILTERS - comma separated list of container filters for inclusion by docker-gen.
160-
Filters supplied through this variable override filters supplied through the -container-filter options.
160+
Filters supplied through this variable are ignored if -container-filter is provided.
161161
```
162162

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

cmd/docker-gen/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Environment Variables:
8787
DOCKER_CERT_PATH - directory path containing key.pem, cert.pem and ca.pem
8888
DOCKER_TLS_VERIFY - enable client TLS verification
8989
DOCKER_CONTAINER_FILTERS - comma separated list of container filters for inclusion by docker-gen.
90-
Filters supplied through this variable override filters supplied through the -container-filter options.
90+
Filters supplied through this variable are ignored if -container-filter is provided.
9191
`)
9292
println(`For more information, see https://github.com/nginx-proxy/docker-gen`)
9393
}
@@ -152,8 +152,8 @@ func initFlags() {
152152
flag.Usage = usage
153153
flag.Parse()
154154

155-
// override containerFilter with DOCKER_CONTAINER_FILTERS environment variable
156-
if filtersEnvVar, found := os.LookupEnv("DOCKER_CONTAINER_FILTERS"); found && filtersEnvVar != "" {
155+
// set containerFilter with DOCKER_CONTAINER_FILTERS if it's set and no -container-filter option was provided
156+
if filtersEnvVar, found := os.LookupEnv("DOCKER_CONTAINER_FILTERS"); found && len(containerFilter) == 0 {
157157
var nonBlankFilters []string
158158

159159
for filter := range strings.SplitSeq(filtersEnvVar, ",") {

0 commit comments

Comments
 (0)