From c409383dbcbee08da7c7ece344f1ba623e04139c Mon Sep 17 00:00:00 2001 From: "Giau. Tran Minh" <12751435+giautm@users.noreply.github.com> Date: Tue, 13 May 2025 03:41:08 +0700 Subject: [PATCH] cli/cli/port: use `len()` to check frontends ports This ensure the command won't print an empty output if the `frontends` port is nil Signed-off-by: Giau. Tran Minh --- cli/command/container/port.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/command/container/port.go b/cli/command/container/port.go index 915ecf057d..3ed950f375 100644 --- a/cli/command/container/port.go +++ b/cli/command/container/port.go @@ -68,7 +68,7 @@ func runPort(ctx context.Context, dockerCli command.Cli, opts *portOptions) erro return errors.Wrapf(err, "Error: invalid port (%s)", port) } frontends, exists := c.NetworkSettings.Ports[nat.Port(port+"/"+proto)] - if !exists || frontends == nil { + if !exists || len(frontends) == 0 { return errors.Errorf("Error: No public port '%s' published for %s", opts.port, opts.container) } for _, frontend := range frontends {