Only return published ports for docker port

This commit is contained in:
Michael Crosby 2013-11-29 16:45:20 -08:00
parent 82cecb34b5
commit 65db62619c
1 changed files with 4 additions and 8 deletions

View File

@ -763,16 +763,12 @@ func (cli *DockerCli) CmdPort(args ...string) error {
return err return err
} }
if frontends, exists := out.NetworkSettings.Ports[Port(port+"/"+proto)]; exists { if frontends, exists := out.NetworkSettings.Ports[Port(port+"/"+proto)]; exists && frontends != nil {
if frontends == nil { for _, frontend := range frontends {
fmt.Fprintf(cli.out, "%s\n", port) fmt.Fprintf(cli.out, "%s:%s\n", frontend.HostIp, frontend.HostPort)
} else {
for _, frontend := range frontends {
fmt.Fprintf(cli.out, "%s:%s\n", frontend.HostIp, frontend.HostPort)
}
} }
} else { } 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 return nil
} }