mirror of
https://github.com/containers/podman.git
synced 2025-12-09 23:27:09 +08:00
show container ports of network namespace
in cases where a container is part of a network namespace, we should show the network namespace's ports when dealing with ports. this impacts ps, kube, and port. fixes: #846 Signed-off-by: baude <bbaude@redhat.com>
This commit is contained in:
@@ -125,8 +125,13 @@ func portCmd(c *cliconfig.PortValues) error {
|
||||
if c.All {
|
||||
fmt.Println(con.ID())
|
||||
}
|
||||
|
||||
portmappings, err := con.PortMappings()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Iterate mappings
|
||||
for _, v := range con.Config().PortMappings {
|
||||
for _, v := range portmappings {
|
||||
hostIP := v.HostIP
|
||||
// Set host IP to 0.0.0.0 if blank
|
||||
if hostIP == "" {
|
||||
|
||||
@@ -213,11 +213,16 @@ func NewBatchContainer(ctr *libpod.Container, opts PsOptions) (PsContainerOutput
|
||||
}
|
||||
}
|
||||
|
||||
ports, err := ctr.PortMappings()
|
||||
if err != nil {
|
||||
logrus.Errorf("unable to lookup namespace container for %s", ctr.ID())
|
||||
}
|
||||
|
||||
pso.ID = cid
|
||||
pso.Image = imageName
|
||||
pso.Command = command
|
||||
pso.Created = created
|
||||
pso.Ports = portsToString(ctr.PortMappings())
|
||||
pso.Ports = portsToString(ports)
|
||||
pso.Names = ctr.Name()
|
||||
pso.IsInfra = ctr.IsInfra()
|
||||
pso.Status = status
|
||||
|
||||
Reference in New Issue
Block a user