Merge pull request #14290 from kgibm/issue12658

Special case port mapping publish on macOS
pull/14177/head
Steven Powell 2022-06-08 11:09:20 -07:00 committed by GitHub
commit c099c054b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -488,8 +488,13 @@ func generatePortMappings(portMappings ...PortMapping) []string {
for _, pm := range portMappings {
// let docker pick a host port by leaving it as ::
// example --publish=127.0.0.17::8443 will get a random host port for 8443
publish := fmt.Sprintf("--publish=%s::%d", pm.ListenAddress, pm.ContainerPort)
result = append(result, publish)
if runtime.GOOS == "darwin" {
publish := fmt.Sprintf("--publish=%d", pm.ContainerPort)
result = append(result, publish)
} else {
publish := fmt.Sprintf("--publish=%s::%d", pm.ListenAddress, pm.ContainerPort)
result = append(result, publish)
}
}
return result
}