From d54dec4d8b6f36fa9211e7a3379f7e949c40b0ce Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Mon, 12 May 2014 15:26:23 -0700 Subject: [PATCH] Fix port mapping in ps display for public and private Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- api/common.go | 7 ++++--- daemon/network_settings.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/common.go b/api/common.go index af4ced4f6e..f4e31a970b 100644 --- a/api/common.go +++ b/api/common.go @@ -2,11 +2,12 @@ package api import ( "fmt" + "mime" + "strings" + "github.com/dotcloud/docker/engine" "github.com/dotcloud/docker/pkg/version" "github.com/dotcloud/docker/utils" - "mime" - "strings" ) const ( @@ -30,7 +31,7 @@ func DisplayablePorts(ports *engine.Table) string { ports.Sort() for _, port := range ports.Data { if port.Get("IP") == "" { - result = append(result, fmt.Sprintf("%d/%s", port.GetInt("PublicPort"), port.Get("Type"))) + result = append(result, fmt.Sprintf("%d/%s", port.GetInt("PrivatePort"), port.Get("Type"))) } else { result = append(result, fmt.Sprintf("%s:%d->%d/%s", port.Get("IP"), port.GetInt("PublicPort"), port.GetInt("PrivatePort"), port.Get("Type"))) } diff --git a/daemon/network_settings.go b/daemon/network_settings.go index 762270362b..a5c750acfe 100644 --- a/daemon/network_settings.go +++ b/daemon/network_settings.go @@ -23,7 +23,7 @@ func (settings *NetworkSettings) PortMappingAPI() *engine.Table { p, _ := nat.ParsePort(port.Port()) if len(bindings) == 0 { out := &engine.Env{} - out.SetInt("PublicPort", p) + out.SetInt("PrivatePort", p) out.Set("Type", port.Proto()) outs.Add(out) continue