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

28722: List of containers with networkID filter is not working

Signed-off-by: dattatrayakumbhar04 <dattatraya.kumbhar@gslab.com>
This commit is contained in:
dattatrayakumbhar04 2016-11-22 20:02:46 +00:00 committed by Dattatraya Kumbhar
parent 05cd8bec32
commit 59b70cdabe
2 changed files with 18 additions and 1 deletions

View file

@ -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
}
}

View file

@ -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) {