소스 검색

28722: List of containers with networkID filter is not working

Signed-off-by: dattatrayakumbhar04 <dattatraya.kumbhar@gslab.com>
dattatrayakumbhar04 8 년 전
부모
커밋
59b70cdabe
2개의 변경된 파일18개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      daemon/list.go
  2. 17 0
      integration-cli/docker_cli_ps_test.go

+ 1 - 1
daemon/list.go

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

+ 17 - 0
integration-cli/docker_cli_ps_test.go

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