New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[carry 22894] Adding network filter to docker ps command #23300

Merged
merged 2 commits into from Jun 7, 2016

Conversation

Projects
None yet
4 participants
@thaJeztah
Member

thaJeztah commented Jun 6, 2016

closes #22894

- What I did

Carry of #22894, rebased, and adding filter by network id.

- How to verify it

docker run -d --net=bridge --name=onbridgenetwork busybox top
docker run -d --net=none --name=onnonenetwork busybox top

docker ps --filter network=bridge 

Output should show only the container with name "onbridgenetwork"

docker ps --filter network=bridge --filter network=none

Output should show both the containers "onbrigenetwork" and "onnonenetwork"

$ docker network inspect --format "{{.ID}}" net1
8c0b4110ae930dbe26b258de9bc34a03f98056ed6f27f991d32919bfe401d7c5

$ docker ps --filter network=8c0b4110ae930dbe26b258de9bc34a03f98056ed6f27f991d32919bfe401d7c5

Output should only show the onbridgenetwork container

- Description for the changelog

Add support for docker ps --filter network=<network-id | network-name> to filter containers by the network(s) they're connected to.

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jun 6, 2016

Member

ping @vdemeester @cpuguy83; moved this back to code-review because of the latest changes

Member

thaJeztah commented Jun 6, 2016

ping @vdemeester @cpuguy83; moved this back to code-review because of the latest changes

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jun 6, 2016

Member

Hm, guess Windows doesn't have "bridge" network, so I should make that dependent on platform

10:34:51 ----------------------------------------------------------------------
10:34:51 FAIL: docker_cli_ps_test.go:808: DockerSuite.TestPsListContainersFilterNetwork
10:34:51 
10:34:51 docker_cli_ps_test.go:810:
10:34:51     // create a container
10:34:51     runSleepingContainer(c, "--net=bridge", "--name=onbridgenetwork")
10:34:51 C:/gopath/src/github.com/docker/docker/pkg/integration/dockerCmd_utils.go:42:
10:34:51     c.Assert(err, check.IsNil, check.Commentf(quote+"%v"+quote+" failed with errors: %s, %v", strings.Join(args, " "), out, err))
10:34:51 ... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc08247e980)} ("exit status 125")
10:34:51 ... "run -d --net=bridge --name=onbridgenetwork busybox sleep 240" failed with errors: D:\CI\CI-cbfb366\binary\docker.exe: Error response from daemon: network bridge not found.
10:34:51 See 'D:\CI\CI-cbfb366\binary\docker.exe run --help'.
10:34:51 , exit status 125
Member

thaJeztah commented Jun 6, 2016

Hm, guess Windows doesn't have "bridge" network, so I should make that dependent on platform

10:34:51 ----------------------------------------------------------------------
10:34:51 FAIL: docker_cli_ps_test.go:808: DockerSuite.TestPsListContainersFilterNetwork
10:34:51 
10:34:51 docker_cli_ps_test.go:810:
10:34:51     // create a container
10:34:51     runSleepingContainer(c, "--net=bridge", "--name=onbridgenetwork")
10:34:51 C:/gopath/src/github.com/docker/docker/pkg/integration/dockerCmd_utils.go:42:
10:34:51     c.Assert(err, check.IsNil, check.Commentf(quote+"%v"+quote+" failed with errors: %s, %v", strings.Join(args, " "), out, err))
10:34:51 ... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc08247e980)} ("exit status 125")
10:34:51 ... "run -d --net=bridge --name=onbridgenetwork busybox sleep 240" failed with errors: D:\CI\CI-cbfb366\binary\docker.exe: Error response from daemon: network bridge not found.
10:34:51 See 'D:\CI\CI-cbfb366\binary\docker.exe run --help'.
10:34:51 , exit status 125
@cpuguy83

This comment has been minimized.

Show comment
Hide comment
@cpuguy83

cpuguy83 Jun 6, 2016

Contributor

Yeah, windows has a "nat" network.

Contributor

cpuguy83 commented Jun 6, 2016

Yeah, windows has a "nat" network.

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jun 6, 2016

Member

I'll just create a custom network, then I don't have to make platform-specific changes

Member

thaJeztah commented Jun 6, 2016

I'll just create a custom network, then I don't have to make platform-specific changes

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jun 6, 2016

Member

Well, I'll be. Doesn't windows support dashes in network names?

15:27:19 FAIL: docker_cli_ps_test.go:808: DockerSuite.TestPsListContainersFilterNetwork
15:27:19 
15:27:19 docker_cli_ps_test.go:810:
15:27:19     // create a network, and some containers
15:27:19     dockerCmd(c, "network", "create", "network-a")
15:27:19 C:/gopath/src/github.com/docker/docker/pkg/integration/dockerCmd_utils.go:42:
15:27:19     c.Assert(err, check.IsNil, check.Commentf(quote+"%v"+quote+" failed with errors: %s, %v", strings.Join(args, " "), out, err))
15:27:19 ... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc082400180)} ("exit status 1")
15:27:19 ... "network create network-a" failed with errors: Error response from daemon: plugin not found
15:27:19 , exit status 1
15:27:19 

@msabansal is that a known issue?

let me rename that network for now

Member

thaJeztah commented Jun 6, 2016

Well, I'll be. Doesn't windows support dashes in network names?

15:27:19 FAIL: docker_cli_ps_test.go:808: DockerSuite.TestPsListContainersFilterNetwork
15:27:19 
15:27:19 docker_cli_ps_test.go:810:
15:27:19     // create a network, and some containers
15:27:19     dockerCmd(c, "network", "create", "network-a")
15:27:19 C:/gopath/src/github.com/docker/docker/pkg/integration/dockerCmd_utils.go:42:
15:27:19     c.Assert(err, check.IsNil, check.Commentf(quote+"%v"+quote+" failed with errors: %s, %v", strings.Join(args, " "), out, err))
15:27:19 ... value *exec.ExitError = &exec.ExitError{ProcessState:(*os.ProcessState)(0xc082400180)} ("exit status 1")
15:27:19 ... "network create network-a" failed with errors: Error response from daemon: plugin not found
15:27:19 , exit status 1
15:27:19 

@msabansal is that a known issue?

let me rename that network for now

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jun 6, 2016

Member

Opened an issue for the Windows issue; #23314

Member

thaJeztah commented Jun 6, 2016

Opened an issue for the Windows issue; #23314

Show outdated Hide outdated integration-cli/docker_cli_ps_test.go
@@ -804,3 +804,60 @@ func (s *DockerSuite) TestPsFormatSize(c *check.C) {
lines = strings.Split(out, "\n")
c.Assert(lines[8], checker.HasPrefix, "size:", check.Commentf("Size should be appended on a newline"))
}
func (s *DockerSuite) TestPsListContainersFilterNetwork(c *check.C) {
// create a network, and some containers

This comment has been minimized.

@vdemeester

vdemeester Jun 7, 2016

Member

Let's add a TODO and a requires DaemonIsLinux on that then 👼

@vdemeester

vdemeester Jun 7, 2016

Member

Let's add a TODO and a requires DaemonIsLinux on that then 👼

This comment has been minimized.

@thaJeztah

thaJeztah Jun 7, 2016

Member

Or make it conditional, and filter on "nat" for windows. Didn't come round to do this yet, will try to do so later today

@thaJeztah

thaJeztah Jun 7, 2016

Member

Or make it conditional, and filter on "nat" for windows. Didn't come round to do this yet, will try to do so later today

Sainath Grandhi and others added some commits May 27, 2016

Adding network filter to docker ps command
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
add support for filtering by network ID
This adds support for filtering by network ID, to be
consistent with other filter options.

Note that only *full* matches are returned; this is
consistent with other filters (e.g. volume), that
also return full matches only.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jun 7, 2016

Member

@vdemeester disabled the test for now on Windows, and added a TODO

Member

thaJeztah commented Jun 7, 2016

@vdemeester disabled the test for now on Windows, and added a TODO

@vdemeester

This comment has been minimized.

Show comment
Hide comment
@vdemeester

vdemeester Jun 7, 2016

Member

LGTM 🐮

Member

vdemeester commented Jun 7, 2016

LGTM 🐮

@cpuguy83

This comment has been minimized.

Show comment
Hide comment
@cpuguy83

cpuguy83 Jun 7, 2016

Contributor

LGTM

Contributor

cpuguy83 commented Jun 7, 2016

LGTM

@cpuguy83

This comment has been minimized.

Show comment
Hide comment
@cpuguy83

cpuguy83 Jun 7, 2016

Contributor

And win2lin finished but didn't notify. Merging.

Contributor

cpuguy83 commented Jun 7, 2016

And win2lin finished but didn't notify. Merging.

@cpuguy83

This comment has been minimized.

Show comment
Hide comment
@cpuguy83

cpuguy83 Jun 7, 2016

Contributor

Actually, let me set it to docs-review :)

Contributor

cpuguy83 commented Jun 7, 2016

Actually, let me set it to docs-review :)

@vdemeester

This comment has been minimized.

Show comment
Hide comment
@vdemeester

vdemeester Jun 7, 2016

Member

docs LGTM 🐮

Member

vdemeester commented Jun 7, 2016

docs LGTM 🐮

@thaJeztah

This comment has been minimized.

Show comment
Hide comment
@thaJeztah

thaJeztah Jun 7, 2016

Member

author LGTM

Member

thaJeztah commented Jun 7, 2016

author LGTM

@thaJeztah thaJeztah merged commit 06a204c into moby:master Jun 7, 2016

6 of 7 checks passed

win2lin Jenkins build Docker-PRs-Win2Lin 26994 is running
Details
docker/dco-signed All commits signed
Details
experimental Jenkins build Docker-PRs-experimental 19629 has succeeded
Details
gccgo Jenkins build Docker-PRs-gccgo 6489 has succeeded
Details
janky Jenkins build Docker-PRs 28428 has succeeded
Details
userns Jenkins build Docker-PRs-userns 10589 has succeeded
Details
windowsTP5 Jenkins build Docker-PRs-WoW-TP5 2868 has succeeded
Details

@thaJeztah thaJeztah deleted the thaJeztah:carry-22894-ps_filter_network branch Jun 7, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment