fix port discovery for docker

This commit is contained in:
yusing 2024-03-12 16:46:17 +00:00
parent 110bb362b3
commit 1fd7b50010
2 changed files with 4 additions and 2 deletions

Binary file not shown.

View file

@ -46,7 +46,9 @@ func (p *Provider) getContainerProxyConfigs(container types.Container, clientIP
if config.Port == "" && clientIP != "" { if config.Port == "" && clientIP != "" {
for _, port := range container.Ports { for _, port := range container.Ports {
config.Port = fmt.Sprintf("%d", port.PublicPort) config.Port = fmt.Sprintf("%d", port.PublicPort)
break if config.Port != "0" {
break
}
} }
} else if config.Port == "" { } else if config.Port == "" {
// usually the smaller port is the http one // usually the smaller port is the http one
@ -63,7 +65,7 @@ func (p *Provider) getContainerProxyConfigs(container types.Container, clientIP
} }
} }
} }
if config.Port == "" { if config.Port == "" || config.Port == "0" {
// no ports exposed or specified // no ports exposed or specified
p.Logf("Build", "no ports exposed for %s, ignored", container_name) p.Logf("Build", "no ports exposed for %s, ignored", container_name)
continue continue