smarter port selection

This commit is contained in:
yusing
2024-03-29 13:35:10 +00:00
parent fdab026a3b
commit 73dfc17a82
3 changed files with 20 additions and 1 deletions

View File

@@ -201,6 +201,11 @@ func selectPort(c *types.Container) uint16 {
}
func selectPortInternal(c *types.Container, getPort func(types.Port) uint16) uint16 {
for _, p := range c.Ports {
if isWellKnownHTTPPort(p.PrivatePort) {
return getPort(p)
}
}
for _, p := range c.Ports {
if port := getPort(p); port != 0 {
return port
@@ -208,3 +213,8 @@ func selectPortInternal(c *types.Container, getPort func(types.Port) uint16) uin
}
return 0
}
func isWellKnownHTTPPort(port uint16) bool {
_, ok := wellKnownHTTPPorts[port]
return ok
}