github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/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/cli GitHub
     8       repository at https://github.com/docker/cli/. 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  ## Description
    35  
    36  Lists all the networks the Engine `daemon` knows about. This includes the
    37  networks that span across multiple hosts in a cluster.
    38  
    39  ## Examples
    40  
    41  ### List all networks
    42  
    43  ```bash
    44  $ sudo docker network ls
    45  NETWORK ID          NAME                DRIVER          SCOPE
    46  7fca4eb8c647        bridge              bridge          local
    47  9f904ee27bf5        none                null            local
    48  cf03ee007fb4        host                host            local
    49  78b03ee04fc4        multi-host          overlay         swarm
    50  ```
    51  
    52  Use the `--no-trunc` option to display the full network id:
    53  
    54  ```bash
    55  $ docker network ls --no-trunc
    56  NETWORK ID                                                         NAME                DRIVER           SCOPE
    57  18a2866682b85619a026c81b98a5e375bd33e1b0936a26cc497c283d27bae9b3   none                null             local
    58  c288470c46f6c8949c5f7e5099b5b7947b07eabe8d9a27d79a9cbf111adcbf47   host                host             local
    59  7b369448dccbf865d397c8d2be0cda7cf7edc6b0945f77d2529912ae917a0185   bridge              bridge           local
    60  95e74588f40db048e86320c6526440c504650a1ff3e9f7d60a497c4d2163e5bd   foo                 bridge           local
    61  63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161   dev                 bridge           local
    62  ```
    63  
    64  ### Filtering
    65  
    66  The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
    67  is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
    68  Multiple filter flags are combined as an `OR` filter. For example,
    69  `-f type=custom -f type=builtin` returns both `custom` and `builtin` networks.
    70  
    71  The currently supported filters are:
    72  
    73  * driver
    74  * id (network's id)
    75  * label (`label=<key>` or `label=<key>=<value>`)
    76  * name (network's name)
    77  * scope (`swarm|global|local`)
    78  * type (`custom|builtin`)
    79  
    80  #### Driver
    81  
    82  The `driver` filter matches networks based on their driver.
    83  
    84  The following example matches networks with the `bridge` driver:
    85  
    86  ```bash
    87  $ docker network ls --filter driver=bridge
    88  NETWORK ID          NAME                DRIVER            SCOPE
    89  db9db329f835        test1               bridge            local
    90  f6e212da9dfd        test2               bridge            local
    91  ```
    92  
    93  #### ID
    94  
    95  The `id` filter matches on all or part of a network's ID.
    96  
    97  The following filter matches all networks with an ID containing the
    98  `63d1ff1f77b0...` string.
    99  
   100  ```bash
   101  $ docker network ls --filter id=63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161
   102  NETWORK ID          NAME                DRIVER           SCOPE
   103  63d1ff1f77b0        dev                 bridge           local
   104  ```
   105  
   106  You can also filter for a substring in an ID as this shows:
   107  
   108  ```bash
   109  $ docker network ls --filter id=95e74588f40d
   110  NETWORK ID          NAME                DRIVER          SCOPE
   111  95e74588f40d        foo                 bridge          local
   112  
   113  $ docker network ls --filter id=95e
   114  NETWORK ID          NAME                DRIVER          SCOPE
   115  95e74588f40d        foo                 bridge          local
   116  ```
   117  
   118  #### Label
   119  
   120  The `label` filter matches networks based on the presence of a `label` alone or a `label` and a
   121  value.
   122  
   123  The following filter matches networks with the `usage` label regardless of its value.
   124  
   125  ```bash
   126  $ docker network ls -f "label=usage"
   127  NETWORK ID          NAME                DRIVER         SCOPE
   128  db9db329f835        test1               bridge         local
   129  f6e212da9dfd        test2               bridge         local
   130  ```
   131  
   132  The following filter matches networks with the `usage` label with the `prod` value.
   133  
   134  ```bash
   135  $ docker network ls -f "label=usage=prod"
   136  NETWORK ID          NAME                DRIVER        SCOPE
   137  f6e212da9dfd        test2               bridge        local
   138  ```
   139  
   140  #### Name
   141  
   142  The `name` filter matches on all or part of a network's name.
   143  
   144  The following filter matches all networks with a name containing the `foobar` string.
   145  
   146  ```bash
   147  $ docker network ls --filter name=foobar
   148  NETWORK ID          NAME                DRIVER       SCOPE
   149  06e7eef0a170        foobar              bridge       local
   150  ```
   151  
   152  You can also filter for a substring in a name as this shows:
   153  
   154  ```bash
   155  $ docker network ls --filter name=foo
   156  NETWORK ID          NAME                DRIVER       SCOPE
   157  95e74588f40d        foo                 bridge       local
   158  06e7eef0a170        foobar              bridge       local
   159  ```
   160  
   161  #### Scope
   162  
   163  The `scope` filter matches networks based on their scope.
   164  
   165  The following example matches networks with the `swarm` scope:
   166  
   167  ```bash
   168  $ docker network ls --filter scope=swarm
   169  NETWORK ID          NAME                DRIVER              SCOPE
   170  xbtm0v4f1lfh        ingress             overlay             swarm
   171  ic6r88twuu92        swarmnet            overlay             swarm
   172  ```
   173  
   174  The following example matches networks with the `local` scope:
   175  
   176  ```bash
   177  $ docker network ls --filter scope=local
   178  NETWORK ID          NAME                DRIVER              SCOPE
   179  e85227439ac7        bridge              bridge              local
   180  0ca0e19443ed        host                host                local
   181  ca13cc149a36        localnet            bridge              local
   182  f9e115d2de35        none                null                local
   183  ```
   184  
   185  #### Type
   186  
   187  The `type` filter supports two values; `builtin` displays predefined networks
   188  (`bridge`, `none`, `host`), whereas `custom` displays user defined networks.
   189  
   190  The following filter matches all user defined networks:
   191  
   192  ```bash
   193  $ docker network ls --filter type=custom
   194  NETWORK ID          NAME                DRIVER       SCOPE
   195  95e74588f40d        foo                 bridge       local  
   196  63d1ff1f77b0        dev                 bridge       local
   197  ```
   198  
   199  By having this flag it allows for batch cleanup. For example, use this filter
   200  to delete all user defined networks:
   201  
   202  ```bash
   203  $ docker network rm `docker network ls --filter type=custom -q`
   204  ```
   205  
   206  A warning will be issued when trying to remove a network that has containers
   207  attached.
   208  
   209  ### Formatting
   210  
   211  The formatting options (`--format`) pretty-prints networks output
   212  using a Go template.
   213  
   214  Valid placeholders for the Go template are listed below:
   215  
   216  Placeholder  | Description
   217  -------------|------------------------------------------------------------------------------------------
   218  `.ID`        | Network ID
   219  `.Name`      | Network name
   220  `.Driver`    | Network driver
   221  `.Scope`     | Network scope (local, global)
   222  `.IPv6`      | Whether IPv6 is enabled on the network or not.
   223  `.Internal`  | Whether the network is internal or not.
   224  `.Labels`    | All labels assigned to the network.
   225  `.Label`     | Value of a specific label for this network. For example `{{.Label "project.version"}}`
   226  `.CreatedAt` | Time when the network was created
   227  
   228  When using the `--format` option, the `network ls` command will either
   229  output the data exactly as the template declares or, when using the
   230  `table` directive, includes column headers as well.
   231  
   232  The following example uses a template without headers and outputs the
   233  `ID` and `Driver` entries separated by a colon for all networks:
   234  
   235  ```bash
   236  $ docker network ls --format "{{.ID}}: {{.Driver}}"
   237  afaaab448eb2: bridge
   238  d1584f8dc718: host
   239  391df270dc66: null
   240  ```
   241  
   242  ## Related commands
   243  
   244  * [network disconnect ](network_disconnect.md)
   245  * [network connect](network_connect.md)
   246  * [network create](network_create.md)
   247  * [network inspect](network_inspect.md)
   248  * [network rm](network_rm.md)
   249  * [network prune](network_prune.md)
   250  * [Understand Docker container networks](https://docs.docker.com/engine/userguide/networking/)