github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/docs/reference/commandline/network_ls.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "network ls"
     4  description = "The network ls command description and usage"
     5  keywords = ["network, list, user-defined"]
     6  [menu.main]
     7  parent = "smn_cli"
     8  +++
     9  <![end-metadata]-->
    10  
    11  # docker network ls
    12  
    13  ```markdown
    14  Usage:  docker network ls [OPTIONS]
    15  
    16  List networks
    17  
    18  Aliases:
    19    ls, list
    20  
    21  Options:
    22    -f, --filter value   Provide filter values (i.e. 'dangling=true') (default [])
    23        --format string  Pretty-print networks using a Go template
    24        --help           Print usage
    25        --no-trunc       Do not truncate the output
    26    -q, --quiet          Only display network IDs
    27  ```
    28  
    29  Lists all the networks the Engine `daemon` knows about. This includes the
    30  networks that span across multiple hosts in a cluster, for example:
    31  
    32  ```bash
    33      $ sudo docker network ls
    34      NETWORK ID          NAME                DRIVER
    35      7fca4eb8c647        bridge              bridge
    36      9f904ee27bf5        none                null
    37      cf03ee007fb4        host                host
    38      78b03ee04fc4        multi-host          overlay
    39  ```
    40  
    41  Use the `--no-trunc` option to display the full network id:
    42  
    43  ```bash
    44  docker network ls --no-trunc
    45  NETWORK ID                                                         NAME                DRIVER
    46  18a2866682b85619a026c81b98a5e375bd33e1b0936a26cc497c283d27bae9b3   none                null
    47  c288470c46f6c8949c5f7e5099b5b7947b07eabe8d9a27d79a9cbf111adcbf47   host                host
    48  7b369448dccbf865d397c8d2be0cda7cf7edc6b0945f77d2529912ae917a0185   bridge              bridge
    49  95e74588f40db048e86320c6526440c504650a1ff3e9f7d60a497c4d2163e5bd   foo                 bridge
    50  63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161   dev                 bridge
    51  ```
    52  
    53  ## Filtering
    54  
    55  The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
    56  is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
    57  Multiple filter flags are combined as an `OR` filter. For example,
    58  `-f type=custom -f type=builtin` returns both `custom` and `builtin` networks.
    59  
    60  The currently supported filters are:
    61  
    62  * driver
    63  * id (network's id)
    64  * label (`label=<key>` or `label=<key>=<value>`)
    65  * name (network's name)
    66  * type (custom|builtin)
    67  
    68  #### Driver
    69  
    70  The `driver` filter matches networks based on their driver.
    71  
    72  The following example matches networks with the `bridge` driver:
    73  
    74  ```bash
    75  $ docker network ls --filter driver=bridge
    76  NETWORK ID          NAME                DRIVER
    77  db9db329f835        test1               bridge
    78  f6e212da9dfd        test2               bridge
    79  ```
    80  
    81  #### ID
    82  
    83  The `id` filter matches on all or part of a network's ID.
    84  
    85  The following filter matches all networks with an ID containing the
    86  `63d1ff1f77b0...` string.
    87  
    88  ```bash
    89  $ docker network ls --filter id=63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161
    90  NETWORK ID          NAME                DRIVER
    91  63d1ff1f77b0        dev                 bridge
    92  ```
    93  
    94  You can also filter for a substring in an ID as this shows:
    95  
    96  ```bash
    97  $ docker network ls --filter id=95e74588f40d
    98  NETWORK ID          NAME                DRIVER
    99  95e74588f40d        foo                 bridge
   100  
   101  $ docker network ls --filter id=95e
   102  NETWORK ID          NAME                DRIVER
   103  95e74588f40d        foo                 bridge
   104  ```
   105  
   106  #### Label
   107  
   108  The `label` filter matches networks based on the presence of a `label` alone or a `label` and a
   109  value.
   110  
   111  The following filter matches networks with the `usage` label regardless of its value.
   112  
   113  ```bash
   114  $ docker network ls -f "label=usage"
   115  NETWORK ID          NAME                DRIVER
   116  db9db329f835        test1               bridge
   117  f6e212da9dfd        test2               bridge
   118  ```
   119  
   120  The following filter matches networks with the `usage` label with the `prod` value.
   121  
   122  ```bash
   123  $ docker network ls -f "label=usage=prod"
   124  NETWORK ID          NAME                DRIVER
   125  f6e212da9dfd        test2               bridge
   126  ```
   127  
   128  #### Name
   129  
   130  The `name` filter matches on all or part of a network's name.
   131  
   132  The following filter matches all networks with a name containing the `foobar` string.
   133  
   134  ```bash
   135  $ docker network ls --filter name=foobar
   136  NETWORK ID          NAME                DRIVER
   137  06e7eef0a170        foobar              bridge
   138  ```
   139  
   140  You can also filter for a substring in a name as this shows:
   141  
   142  ```bash
   143  $ docker network ls --filter name=foo
   144  NETWORK ID          NAME                DRIVER
   145  95e74588f40d        foo                 bridge
   146  06e7eef0a170        foobar              bridge
   147  ```
   148  
   149  #### Type
   150  
   151  The `type` filter supports two values; `builtin` displays predefined networks
   152  (`bridge`, `none`, `host`), whereas `custom` displays user defined networks.
   153  
   154  The following filter matches all user defined networks:
   155  
   156  ```bash
   157  $ docker network ls --filter type=custom
   158  NETWORK ID          NAME                DRIVER
   159  95e74588f40d        foo                 bridge
   160  63d1ff1f77b0        dev                 bridge
   161  ```
   162  
   163  By having this flag it allows for batch cleanup. For example, use this filter
   164  to delete all user defined networks:
   165  
   166  ```bash
   167  $ docker network rm `docker network ls --filter type=custom -q`
   168  ```
   169  
   170  A warning will be issued when trying to remove a network that has containers
   171  attached.
   172  
   173  ## Formatting
   174  
   175  The formatting options (`--format`) pretty-prints networks output
   176  using a Go template.
   177  
   178  Valid placeholders for the Go template are listed below:
   179  
   180  Placeholder | Description
   181  ------------|------------------------------------------------------------------------------------------
   182  `.ID`       | Network ID 
   183  `.Name`     | Network name
   184  `.Driver`   | Network driver
   185  `.Scope`    | Network scope (local, global)
   186  `.IPv6`     | Whether IPv6 is enabled on the network or not.
   187  `.Internal` | Whether the network is internal or not.
   188  `.Labels`   | All labels assigned to the network.
   189  `.Label`    | Value of a specific label for this network. For example `{{.Label "project.version"}}`
   190  
   191  When using the `--format` option, the `network ls` command will either
   192  output the data exactly as the template declares or, when using the
   193  `table` directive, includes column headers as well.
   194  
   195  The following example uses a template without headers and outputs the
   196  `ID` and `Driver` entries separated by a colon for all networks:
   197  
   198  ```bash
   199  $ docker network ls --format "{{.ID}}: {{.Driver}}"
   200  afaaab448eb2: bridge
   201  d1584f8dc718: host
   202  391df270dc66: null
   203  ```
   204  
   205  ## Related information
   206  
   207  * [network disconnect ](network_disconnect.md)
   208  * [network connect](network_connect.md)
   209  * [network create](network_create.md)
   210  * [network inspect](network_inspect.md)
   211  * [network rm](network_rm.md)
   212  * [Understand Docker container networks](../../userguide/networking/index.md)