github.com/olljanat/moby@v1.13.1/docs/reference/commandline/network_ls.md (about)

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