From b754ba975327904e040824e9ca64e7e39c3dde9d Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 7 Oct 2020 14:05:34 -0400 Subject: Ports given only by number should have random host port In Podman 1.9.3, `podman run -p 80` would assign port 80 in the container to a random port on the host. In Podman 2.0 and up, it assigned Port 80 in the container to Port 80 on the host. This is an easy fix, fortunately - just need to remove the bit that assumed host port, if not given, should be set to container port. We also had a test for the bad behavior, so fix it to test for the correct way of doing things. Fixes #7947 Signed-off-by: Matthew Heon --- cmd/podman/common/util.go | 2 -- 1 file changed, 2 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/common/util.go b/cmd/podman/common/util.go index 17e779c86..a971aa957 100644 --- a/cmd/podman/common/util.go +++ b/cmd/podman/common/util.go @@ -200,8 +200,6 @@ func parseSplitPort(hostIP, hostPort *string, ctrPort string, protocol *string) } newPort.HostPort = hostStart } - } else { - newPort.HostPort = newPort.ContainerPort } hport := newPort.HostPort -- cgit v1.2.3-54-g00ecf