From 15594e92e506d6f8e0acac640d4e7c288a8bcd4b Mon Sep 17 00:00:00 2001 From: telday Date: Mon, 30 Jan 2023 13:10:22 -0700 Subject: [PATCH] Fixes port collision issue on use of --publish-all The function which generates and assigns a random port number for the --publish-all functionality was not properly marking some ports as "used". In very rare occasions this can cause a randomly "generated" port to be used twice creating an impossible container configuration. Signed-off-by: telday --- pkg/specgen/generate/ports.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/specgen/generate/ports.go b/pkg/specgen/generate/ports.go index ee75edfeca..782a7f65ac 100644 --- a/pkg/specgen/generate/ports.go +++ b/pkg/specgen/generate/ports.go @@ -311,6 +311,8 @@ func ParsePortMapping(portMappings []types.PortMapping, exposePorts map[uint16][ return nil, err } portMappings = append(portMappings, p) + // Mark this port as used so it doesn't get re-generated + allPorts[p.HostPort] = true } else { newProtocols = append(newProtocols, protocol) }