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 <hello@giautm.dev>
This commit is contained in:
parent
75a57131a8
commit
c409383dbc
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user