1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #12812 from sharidas/8373-display-docker-ps-host

Display when a container is in --net=host in docker ps
This commit is contained in:
David Calavera 2015-06-22 14:06:07 -07:00
commit 74be85500a
3 changed files with 14 additions and 3 deletions

View file

@ -129,8 +129,9 @@ func (cli *DockerCli) CmdPs(args ...string) error {
}
var (
names = stripNamePrefix(container.Names)
command = strconv.Quote(container.Command)
names = stripNamePrefix(container.Names)
command = strconv.Quote(container.Command)
displayPort string
)
if !*noTrunc {
@ -150,9 +151,15 @@ func (cli *DockerCli) CmdPs(args ...string) error {
image = "<no image>"
}
if container.HostConfig.NetworkMode == "host" {
displayPort = "*/tcp, */udp"
} else {
displayPort = api.DisplayablePorts(container.Ports)
}
fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\t%s\t%s\t%s\t", ID, image, command,
units.HumanDuration(time.Now().UTC().Sub(time.Unix(int64(container.Created), 0))),
container.Status, api.DisplayablePorts(container.Ports), strings.Join(names, ","))
container.Status, displayPort, strings.Join(names, ","))
if *size {
if container.SizeRootFs > 0 {

View file

@ -117,6 +117,9 @@ type Container struct {
SizeRootFs int `json:",omitempty"`
Labels map[string]string
Status string
HostConfig struct {
NetworkMode string `json:",omitempty"`
}
}
// POST "/containers/"+containerID+"/copy"

View file

@ -151,6 +151,7 @@ func (daemon *Daemon) Containers(config *ContainersConfig) ([]*types.Container,
}
newC.Created = int(container.Created.Unix())
newC.Status = container.State.String()
newC.HostConfig.NetworkMode = string(container.HostConfig().NetworkMode)
newC.Ports = []types.Port{}
for port, bindings := range container.NetworkSettings.Ports {