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 <ellis.wright@cyberark.com>
This commit is contained in:
telday
2023-01-30 13:10:22 -07:00
parent 929d03a5ea
commit 15594e92e5

View File

@ -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)
}