From a9d1694853e2e354e2c1e863630552d2a0052fa9 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 9 Oct 2022 18:10:45 -0700 Subject: [PATCH] more concise showing of ports --- pkg/commands/container.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/commands/container.go b/pkg/commands/container.go index 2cb60854..c239640d 100644 --- a/pkg/commands/container.go +++ b/pkg/commands/container.go @@ -57,7 +57,14 @@ func (c *Container) GetDisplayStrings(isFocused bool) []string { func (c *Container) displayPorts() string { portStrings := lo.Map(c.Container.Ports, func(port types.Port, _ int) string { - return fmt.Sprintf("%s:%d->%d/%s", port.IP, port.PublicPort, port.PrivatePort, port.Type) + // docker ps will show '0.0.0.0:80->80/tcp' but we'll show + // '80->80/tcp' instead to save space (unless the IP is something other than + // 0.0.0.0) + ipString := "" + if port.IP != "0.0.0.0" { + ipString = port.IP + ":" + } + return fmt.Sprintf("%s%d->%d/%s", ipString, port.PublicPort, port.PrivatePort, port.Type) }) return strings.Join(portStrings, ", ")