Merge pull request #2965 from crosbymichael/no-private-port
Only return published ports for docker port Upstream-commit: 62f0e5aef9726761cde5bc73abdf7c318102203e Component: engine
This commit is contained in:
@ -770,16 +770,12 @@ func (cli *DockerCli) CmdPort(args ...string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if frontends, exists := out.NetworkSettings.Ports[Port(port+"/"+proto)]; exists {
|
||||
if frontends == nil {
|
||||
fmt.Fprintf(cli.out, "%s\n", port)
|
||||
} else {
|
||||
for _, frontend := range frontends {
|
||||
fmt.Fprintf(cli.out, "%s:%s\n", frontend.HostIp, frontend.HostPort)
|
||||
}
|
||||
if frontends, exists := out.NetworkSettings.Ports[Port(port+"/"+proto)]; exists && frontends != nil {
|
||||
for _, frontend := range frontends {
|
||||
fmt.Fprintf(cli.out, "%s:%s\n", frontend.HostIp, frontend.HostPort)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("Error: No private port '%s' allocated on %s", cmd.Arg(1), cmd.Arg(0))
|
||||
return fmt.Errorf("Error: No public port '%s' published for %s", cmd.Arg(1), cmd.Arg(0))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user