diff --git a/docs/reference/commandline/ps.md b/docs/reference/commandline/ps.md index 71c4fe5dc7..c661c653dc 100644 --- a/docs/reference/commandline/ps.md +++ b/docs/reference/commandline/ps.md @@ -62,7 +62,7 @@ The currently supported filters are: * since (container's id or name) - filters containers created since given id or name * isolation (default|process|hyperv) (Windows daemon only) * volume (volume name or mount point) - filters containers that mount volumes. -* network (network name) - filters containers connected to the provided network name +* network (network id or name) - filters containers connected to the provided network #### Label @@ -209,15 +209,33 @@ The `volume` filter shows only containers that mount a specific volume or have a #### Network -The `network` filter shows only containers that has endpoints on the provided network name. +The `network` filter shows only containers that are connected to a network with +a given name or id. - $docker run -d --net=net1 --name=test1 ubuntu top - $docker run -d --net=net2 --name=test2 ubuntu top +The following filter matches all containers that are connected to a network +with a name containing `net1`. - $docker ps --filter network=net1 - CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES - 9d4893ed80fe ubuntu "top" 10 minutes ago Up 10 minutes test1 +```bash +$ docker run -d --net=net1 --name=test1 ubuntu top +$ docker run -d --net=net2 --name=test2 ubuntu top +$ docker ps --filter network=net1 +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +9d4893ed80fe ubuntu "top" 10 minutes ago Up 10 minutes test1 +``` + +The network filter matches on both the network's name and id. The following +example shows all containers that are attached to the `net1` network, using +the network id as a filter; + +```bash +$ docker network inspect --format "{{.ID}}" net1 +8c0b4110ae930dbe26b258de9bc34a03f98056ed6f27f991d32919bfe401d7c5 + +$ docker ps --filter network=8c0b4110ae930dbe26b258de9bc34a03f98056ed6f27f991d32919bfe401d7c5 +CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES +9d4893ed80fe ubuntu "top" 10 minutes ago Up 10 minutes test1 +``` ## Formatting diff --git a/man/docker-ps.1.md b/man/docker-ps.1.md index 0c2404b573..14c770121f 100644 --- a/man/docker-ps.1.md +++ b/man/docker-ps.1.md @@ -36,7 +36,7 @@ the running containers. - since=(|) - ancestor=([:tag]||) - containers created from an image or a descendant. - volume=(|) - - network=() - containers connected to the provided network name + - network=(|) - containers connected to the provided network **--format**="*TEMPLATE*" Pretty-print containers using a Go template.