From b7b86bda2dea8e0cd6b381ede64d1850f3a5e393 Mon Sep 17 00:00:00 2001 From: baude Date: Wed, 7 Aug 2019 09:09:47 -0500 Subject: fix port early return when listing multiple ports on a container with podman port, an early return was limiting results. Fixes: #3747 Signed-off-by: baude --- cmd/podman/port.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'cmd') diff --git a/cmd/podman/port.go b/cmd/podman/port.go index 5753c8e56..4e1f9642c 100644 --- a/cmd/podman/port.go +++ b/cmd/podman/port.go @@ -48,8 +48,8 @@ func init() { func portCmd(c *cliconfig.PortValues) error { var ( - userProto, containerName string - userPort int + userProto string + userPort int ) args := c.InputArgs @@ -106,6 +106,7 @@ func portCmd(c *cliconfig.PortValues) error { if err != nil { return err } + var found bool // Iterate mappings for _, v := range portmappings { hostIP := v.HostIP @@ -125,12 +126,14 @@ func portCmd(c *cliconfig.PortValues) error { if v.ContainerPort == int32(userPort) { if userProto == "" || userProto == v.Protocol { fmt.Printf("%s:%d\n", hostIP, v.HostPort) + found = true break } - } else { - return errors.Errorf("No public port '%d' published for %s", userPort, containerName) } } + if !found && port != "" { + return errors.Errorf("failed to find published port '%d'", userPort) + } } return nil -- cgit v1.2.3-54-g00ecf