mirror of https://github.com/containers/podman.git
Print port mappings in `ps` for ctrs sharing network
In Podman v1.9, we printed port mappings for the container, even if it shared its network namespace (and thus ports) with another container. We regressed on this in Podman v2.0, which is fixed here. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
parent
4ee66598c1
commit
16b3356a89
|
@ -145,11 +145,15 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
|
|||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
if batchErr != nil {
|
||||
return entities.ListContainer{}, batchErr
|
||||
}
|
||||
|
||||
portMappings, err := ctr.PortMappings()
|
||||
if err != nil {
|
||||
return entities.ListContainer{}, err
|
||||
}
|
||||
|
||||
ps := entities.ListContainer{
|
||||
Command: conConfig.Command,
|
||||
Created: conConfig.CreatedTime.Unix(),
|
||||
|
@ -165,7 +169,7 @@ func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities
|
|||
Names: []string{conConfig.Name},
|
||||
Pid: pid,
|
||||
Pod: conConfig.Pod,
|
||||
Ports: conConfig.PortMappings,
|
||||
Ports: portMappings,
|
||||
Size: size,
|
||||
StartedAt: startedTime.Unix(),
|
||||
State: conState.String(),
|
||||
|
|
|
@ -449,4 +449,21 @@ var _ = Describe("Podman ps", func() {
|
|||
Expect(len(output)).To(Equal(1))
|
||||
Expect(output[0]).To(Equal(ctrName))
|
||||
})
|
||||
|
||||
It("podman ps test with port shared with pod", func() {
|
||||
podName := "testPod"
|
||||
pod := podmanTest.Podman([]string{"pod", "create", "-p", "8080:80", "--name", podName})
|
||||
pod.WaitWithDefaultTimeout()
|
||||
Expect(pod.ExitCode()).To(Equal(0))
|
||||
|
||||
ctrName := "testCtr"
|
||||
session := podmanTest.Podman([]string{"run", "--name", ctrName, "-dt", "--pod", podName, ALPINE, "top"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.ExitCode()).To(Equal(0))
|
||||
|
||||
ps := podmanTest.Podman([]string{"ps", "--filter", fmt.Sprintf("name=%s", ctrName), "--format", "{{.Ports}}"})
|
||||
ps.WaitWithDefaultTimeout()
|
||||
Expect(ps.ExitCode()).To(Equal(0))
|
||||
Expect(ps.OutputToString()).To(ContainSubstring("0.0.0.0:8080->80/tcp"))
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue