mirror of https://github.com/docker/cli.git
Add network --format flag to ls
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
parent
24c39ea25b
commit
fd30075463
|
@ -20,6 +20,7 @@ Aliases:
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-f, --filter value Provide filter values (i.e. 'dangling=true') (default [])
|
-f, --filter value Provide filter values (i.e. 'dangling=true') (default [])
|
||||||
|
--format string Pretty-print networks using a Go template
|
||||||
--help Print usage
|
--help Print usage
|
||||||
--no-trunc Do not truncate the output
|
--no-trunc Do not truncate the output
|
||||||
-q, --quiet Only display volume names
|
-q, --quiet Only display volume names
|
||||||
|
@ -169,6 +170,38 @@ $ docker network rm `docker network ls --filter type=custom -q`
|
||||||
A warning will be issued when trying to remove a network that has containers
|
A warning will be issued when trying to remove a network that has containers
|
||||||
attached.
|
attached.
|
||||||
|
|
||||||
|
## Formatting
|
||||||
|
|
||||||
|
The formatting options (`--format`) pretty-prints networks output
|
||||||
|
using a Go template.
|
||||||
|
|
||||||
|
Valid placeholders for the Go template are listed below:
|
||||||
|
|
||||||
|
Placeholder | Description
|
||||||
|
------------|------------------------------------------------------------------------------------------
|
||||||
|
`.ID` | Network ID
|
||||||
|
`.Name` | Network name
|
||||||
|
`.Driver` | Network driver
|
||||||
|
`.Scope` | Network scope (local, global)
|
||||||
|
`.IPv6` | Whether IPv6 is enabled on the network or not.
|
||||||
|
`.Internal` | Whether the network is internal or not.
|
||||||
|
`.Labels` | All labels assigned to the network.
|
||||||
|
`.Label` | Value of a specific label for this network. For example `{{.Label "project.version"}}`
|
||||||
|
|
||||||
|
When using the `--format` option, the `network ls` command will either
|
||||||
|
output the data exactly as the template declares or, when using the
|
||||||
|
`table` directive, includes column headers as well.
|
||||||
|
|
||||||
|
The following example uses a template without headers and outputs the
|
||||||
|
`ID` and `Driver` entries separated by a colon for all networks:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ docker network ls --format "{{.ID}}: {{.Driver}}"
|
||||||
|
afaaab448eb2: bridge
|
||||||
|
d1584f8dc718: host
|
||||||
|
391df270dc66: null
|
||||||
|
```
|
||||||
|
|
||||||
## Related information
|
## Related information
|
||||||
|
|
||||||
* [network disconnect ](network_disconnect.md)
|
* [network disconnect ](network_disconnect.md)
|
||||||
|
|
|
@ -7,6 +7,7 @@ docker-network-ls - list networks
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
**docker network ls**
|
**docker network ls**
|
||||||
[**-f**|**--filter**[=*[]*]]
|
[**-f**|**--filter**[=*[]*]]
|
||||||
|
[**--format**=*"TEMPLATE"*]
|
||||||
[**--no-trunc**[=*true*|*false*]]
|
[**--no-trunc**[=*true*|*false*]]
|
||||||
[**-q**|**--quiet**[=*true*|*false*]]
|
[**-q**|**--quiet**[=*true*|*false*]]
|
||||||
[**--help**]
|
[**--help**]
|
||||||
|
@ -162,6 +163,18 @@ attached.
|
||||||
**-f**, **--filter**=*[]*
|
**-f**, **--filter**=*[]*
|
||||||
filter output based on conditions provided.
|
filter output based on conditions provided.
|
||||||
|
|
||||||
|
**--format**="*TEMPLATE*"
|
||||||
|
Pretty-print networks using a Go template.
|
||||||
|
Valid placeholders:
|
||||||
|
.ID - Network ID
|
||||||
|
.Name - Network name
|
||||||
|
.Driver - Network driver
|
||||||
|
.Scope - Network scope (local, global)
|
||||||
|
.IPv6 - Whether IPv6 is enabled on the network or not
|
||||||
|
.Internal - Whether the network is internal or not
|
||||||
|
.Labels - All labels assigned to the network
|
||||||
|
.Label - Value of a specific label for this network. For example `{{.Label "project.version"}}`
|
||||||
|
|
||||||
**--no-trunc**=*true*|*false*
|
**--no-trunc**=*true*|*false*
|
||||||
Do not truncate the output
|
Do not truncate the output
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue