'docker ps' shows port mappings

Upstream-commit: 931ca464a7db038fa78ee51a3f5c4cbe85db1e21
Component: engine
This commit is contained in:
Solomon Hykes
2013-04-19 19:29:13 -07:00
parent 00b1b1ebe5
commit 82eedaa832
2 changed files with 14 additions and 1 deletions

View File

@ -11,7 +11,9 @@ import (
"os"
"os/exec"
"path"
"sort"
"strconv"
"strings"
"syscall"
"time"
)
@ -150,6 +152,16 @@ type NetworkSettings struct {
PortMapping map[string]string
}
// String returns a human-readable description of the port mapping defined in the settings
func (settings *NetworkSettings) PortMappingHuman() string {
var mapping []string
for private, public := range settings.PortMapping {
mapping = append(mapping, fmt.Sprintf("%s->%s", public, private))
}
sort.Strings(mapping)
return strings.Join(mapping, ", ")
}
func (container *Container) Cmd() *exec.Cmd {
return container.cmd
}