mirror of https://github.com/docker/cli.git
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>
This commit is contained in:
parent
eef6bd0b23
commit
44cc95141e
|
@ -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
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ the running containers.
|
|||
- since=(<container-name>|<container-id>)
|
||||
- ancestor=(<image-name>[:tag]|<image-id>|<image@digest>) - containers created from an image or a descendant.
|
||||
- volume=(<volume-name>|<mount-point-destination>)
|
||||
- network=(<network-name>) - containers connected to the provided network name
|
||||
- network=(<network-name>|<network-id>) - containers connected to the provided network
|
||||
|
||||
**--format**="*TEMPLATE*"
|
||||
Pretty-print containers using a Go template.
|
||||
|
|
Loading…
Reference in New Issue