Merge pull request #1192 from dotcloud/docker_port-fix
hotfix: fix broken docker port
This commit is contained in:
commit
8ff271fc74
|
@ -592,6 +592,13 @@ func (cli *DockerCli) CmdPort(args ...string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
port := cmd.Arg(1)
|
||||||
|
proto := "Tcp"
|
||||||
|
parts := strings.SplitN(port, "/", 2)
|
||||||
|
if len(parts) == 2 && len(parts[1]) != 0 {
|
||||||
|
port = parts[0]
|
||||||
|
proto = strings.ToUpper(parts[1][:1]) + strings.ToLower(parts[1][1:])
|
||||||
|
}
|
||||||
body, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/json", nil)
|
body, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/json", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -602,7 +609,7 @@ func (cli *DockerCli) CmdPort(args ...string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if frontend, exists := out.NetworkSettings.PortMapping[cmd.Arg(1)]; exists {
|
if frontend, exists := out.NetworkSettings.PortMapping[proto][port]; exists {
|
||||||
fmt.Fprintf(cli.out, "%s\n", frontend)
|
fmt.Fprintf(cli.out, "%s\n", frontend)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Errorf("Error: No private port '%s' allocated on %s", cmd.Arg(1), cmd.Arg(0))
|
return fmt.Errorf("Error: No private port '%s' allocated on %s", cmd.Arg(1), cmd.Arg(0))
|
||||||
|
|
Loading…
Reference in New Issue