aboutsummaryrefslogtreecommitdiff
path: root/pkg/specgen
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-07-31 14:06:37 -0400
committerGitHub <noreply@github.com>2020-07-31 14:06:37 -0400
commit87955d8541e553567444b9f3cf2d09982fd9d419 (patch)
treee7e04c86432f498b815c7b1327464680e4318f97 /pkg/specgen
parentb55a0ce42eb836b8d4a7091ea8bdd82e58f8352b (diff)
parenta9a55be991fa8f06cf266bd84a72589713a71ac9 (diff)
downloadpodman-87955d8541e553567444b9f3cf2d09982fd9d419.tar.gz
podman-87955d8541e553567444b9f3cf2d09982fd9d419.tar.bz2
podman-87955d8541e553567444b9f3cf2d09982fd9d419.zip
Merge pull request #7170 from mheon/204_backports
Extra backports for v2.0.4
Diffstat (limited to 'pkg/specgen')
-rw-r--r--pkg/specgen/generate/ports.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/pkg/specgen/generate/ports.go b/pkg/specgen/generate/ports.go
index c8d1c27c5..2125c6b9f 100644
--- a/pkg/specgen/generate/ports.go
+++ b/pkg/specgen/generate/ports.go
@@ -123,19 +123,20 @@ func parsePortMapping(portMappings []specgen.PortMapping) ([]ocicni.PortMapping,
postAssignHostPort = true
}
} else {
- testCPort := ctrPortMap[cPort]
- if testCPort != 0 && testCPort != hPort {
- // This is an attempt to redefine a port
- return nil, nil, nil, errors.Errorf("conflicting port mappings for container port %d (protocol %s)", cPort, p)
- }
- ctrPortMap[cPort] = hPort
-
testHPort := hostPortMap[hPort]
if testHPort != 0 && testHPort != cPort {
return nil, nil, nil, errors.Errorf("conflicting port mappings for host port %d (protocol %s)", hPort, p)
}
hostPortMap[hPort] = cPort
+ // Mapping a container port to multiple
+ // host ports is allowed.
+ // We only store the latest of these in
+ // the container port map - we don't
+ // need to know all of them, just one.
+ testCPort := ctrPortMap[cPort]
+ ctrPortMap[cPort] = hPort
+
// If we have an exact duplicate, just continue
if testCPort == hPort && testHPort == cPort {
continue