Add network --format flag to ls

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
This commit is contained in:
Vincent Demeester
2016-08-04 14:59:51 +02:00
committed by Tibor Vass
parent 24c39ea25b
commit fd30075463
2 changed files with 46 additions and 0 deletions

View File

@ -20,6 +20,7 @@ Aliases:
Options:
-f, --filter value Provide filter values (i.e. 'dangling=true') (default [])
--format string Pretty-print networks using a Go template
--help Print usage
--no-trunc Do not truncate the output
-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
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
* [network disconnect ](network_disconnect.md)