Skip to content

Commit 11414b0

Browse files
committed
skip implicit host creation if it overlaps with explicit
1 parent abfe520 commit 11414b0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

nginx.tmpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,11 @@ server {
8181

8282
{{ range $project, $projContainers := groupByLabel $ "com.docker.compose.project" }}
8383
{{ range $service, $containers := groupByLabel $projContainers "com.docker.compose.service" }}
84-
{{ $container := first $containers }}
8584
{{ $host := printf "%s.%s.%s" $service $project "docker" }}
86-
{{ template "server" (dict "Containers" $containers "Host" $host) }}
85+
{{/* Don't create the implicit host if an explicit VIRTUAL_HOST with the same name has been defined */}}
86+
{{ if eq 0 (len (where $ "Env.VIRTUAL_HOST" $host)) }}
87+
{{ $container := first $containers }}
88+
{{ template "server" (dict "Containers" $containers "Host" $host) }}
89+
{{ end }}
8790
{{ end }}
8891
{{ end }}

0 commit comments

Comments
 (0)