28722: List of containers with networkID filter is not working
Signed-off-by: dattatrayakumbhar04 <dattatraya.kumbhar@gslab.com> Upstream-commit: 59b70cdabe3b5f3592e40d241377c6a9f2127dfc Component: engine
This commit is contained in:
committed by
Dattatraya Kumbhar
parent
b0235f63ee
commit
b3bf6afbcc
@ -504,7 +504,7 @@ func includeContainerInList(container *container.Container, ctx *listContext) it
|
||||
if nw.EndpointSettings == nil {
|
||||
continue
|
||||
}
|
||||
if nw.NetworkID == value {
|
||||
if strings.HasPrefix(nw.NetworkID, value) {
|
||||
return networkExist
|
||||
}
|
||||
}
|
||||
|
||||
@ -877,6 +877,23 @@ func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) {
|
||||
containerOut = strings.TrimSpace(string(out))
|
||||
|
||||
c.Assert(containerOut, checker.Contains, "onbridgenetwork")
|
||||
|
||||
// Filter by partial network ID
|
||||
partialnwID := string(nwID[0:4])
|
||||
|
||||
out, _ = dockerCmd(c, "ps", "--filter", "network="+partialnwID)
|
||||
containerOut = strings.TrimSpace(string(out))
|
||||
|
||||
lines = strings.Split(containerOut, "\n")
|
||||
// skip header
|
||||
lines = lines[1:]
|
||||
|
||||
// ps output should have only one container
|
||||
c.Assert(lines, checker.HasLen, 1)
|
||||
|
||||
// Making sure onbridgenetwork is on the output
|
||||
c.Assert(containerOut, checker.Contains, "onbridgenetwork", check.Commentf("Missing the container on network\n"))
|
||||
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestPsByOrder(c *check.C) {
|
||||
|
||||
Reference in New Issue
Block a user