github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/node_ls.md (about)

     1  ---
     2  title: "node ls"
     3  description: "The node ls command description and usage"
     4  keywords: "node, list"
     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  # node ls
    17  
    18  ```markdown
    19  Usage:  docker node ls [OPTIONS]
    20  
    21  List nodes in the swarm
    22  
    23  Aliases:
    24    ls, list
    25  
    26  Options:
    27    -f, --filter filter   Filter output based on conditions provided
    28        --format string   Pretty-print nodes using a Go template
    29        --help            Print usage
    30    -q, --quiet           Only display IDs
    31  ```
    32  
    33  ## Description
    34  
    35  Lists all the nodes that the Docker Swarm manager knows about. You can filter
    36  using the `-f` or `--filter` flag. Refer to the [filtering](#filtering) section
    37  for more information about available filter options.
    38  
    39  ## Examples
    40  
    41  ```bash
    42  $ docker node ls
    43  
    44  ID                           HOSTNAME        STATUS  AVAILABILITY  MANAGER STATUS
    45  1bcef6utixb0l0ca7gxuivsj0    swarm-worker2   Ready   Active
    46  38ciaotwjuritcdtn9npbnkuz    swarm-worker1   Ready   Active
    47  e216jshn25ckzbvmwlnh5jr3g *  swarm-manager1  Ready   Active        Leader
    48  ```
    49  > **Note**:
    50  > In the above example output, there is a hidden column of `.Self` that indicates if the
    51  > node is the same node as the current docker daemon. A `*` (e.g., `e216jshn25ckzbvmwlnh5jr3g *`)
    52  > means this node is the current docker daemon.
    53  
    54  
    55  ### Filtering
    56  
    57  The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
    58  than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
    59  
    60  The currently supported filters are:
    61  
    62  * [id](node_ls.md#id)
    63  * [label](node_ls.md#label)
    64  * [membership](node_ls.md#membership)
    65  * [name](node_ls.md#name)
    66  * [role](node_ls.md#role)
    67  
    68  #### id
    69  
    70  The `id` filter matches all or part of a node's id.
    71  
    72  ```bash
    73  $ docker node ls -f id=1
    74  
    75  ID                         HOSTNAME       STATUS  AVAILABILITY  MANAGER STATUS
    76  1bcef6utixb0l0ca7gxuivsj0  swarm-worker2  Ready   Active
    77  ```
    78  
    79  #### label
    80  
    81  The `label` filter matches nodes based on engine labels and on the presence of a `label` alone or a `label` and a value. Node labels are currently not used for filtering.
    82  
    83  The following filter matches nodes with the `foo` label regardless of its value.
    84  
    85  ```bash
    86  $ docker node ls -f "label=foo"
    87  
    88  ID                         HOSTNAME       STATUS  AVAILABILITY  MANAGER STATUS
    89  1bcef6utixb0l0ca7gxuivsj0  swarm-worker2  Ready   Active
    90  ```
    91  
    92  #### membership
    93  
    94  The `membership` filter matches nodes based on the presence of a `membership` and a value
    95  `accepted` or `pending`.
    96  
    97  The following filter matches nodes with the `membership` of `accepted`.
    98  
    99  ```bash
   100  $ docker node ls -f "membership=accepted"
   101  
   102  ID                           HOSTNAME        STATUS  AVAILABILITY  MANAGER STATUS
   103  1bcef6utixb0l0ca7gxuivsj0    swarm-worker2   Ready   Active
   104  38ciaotwjuritcdtn9npbnkuz    swarm-worker1   Ready   Active
   105  ```
   106  
   107  #### name
   108  
   109  The `name` filter matches on all or part of a node hostname.
   110  
   111  The following filter matches the nodes with a name equal to `swarm-master` string.
   112  
   113  ```bash
   114  $ docker node ls -f name=swarm-manager1
   115  
   116  ID                           HOSTNAME        STATUS  AVAILABILITY  MANAGER STATUS
   117  e216jshn25ckzbvmwlnh5jr3g *  swarm-manager1  Ready   Active        Leader
   118  ```
   119  
   120  #### role
   121  
   122  The `role` filter matches nodes based on the presence of a `role` and a value `worker` or `manager`.
   123  
   124  The following filter matches nodes with the `manager` role.
   125  
   126  ```bash
   127  $ docker node ls -f "role=manager"
   128  
   129  ID                           HOSTNAME        STATUS  AVAILABILITY  MANAGER STATUS
   130  e216jshn25ckzbvmwlnh5jr3g *  swarm-manager1  Ready   Active        Leader
   131  ```
   132  
   133  ### Formatting
   134  
   135  The formatting options (`--format`) pretty-prints nodes output
   136  using a Go template.
   137  
   138  Valid placeholders for the Go template are listed below:
   139  
   140  Placeholder      | Description
   141  -----------------|------------------------------------------------------------------------------------------
   142  `.ID`            | Node ID
   143  `.Self`          | Node of the daemon (`true/false`, `true`indicates that the node is the same as current docker daemon)
   144  `.Hostname`      | Node hostname
   145  `.Status`        | Node status
   146  `.Availability`  | Node availability ("active", "pause", or "drain")
   147  `.ManagerStatus` | Manager status of the node
   148  `.TLSStatus`     | TLS status of the node ("Ready", or "Needs Rotation" has TLS certificate signed by an old CA)
   149  `.EngineVersion` | Engine version
   150  
   151  When using the `--format` option, the `node ls` command will either
   152  output the data exactly as the template declares or, when using the
   153  `table` directive, includes column headers as well.
   154  
   155  The following example uses a template without headers and outputs the
   156  `ID`, `Hostname`, and `TLS Status` entries separated by a colon for all nodes:
   157  
   158  ```bash
   159  $ docker node ls --format "{{.ID}}: {{.Hostname}} {{.TLSStatus}}"
   160  e216jshn25ckzbvmwlnh5jr3g: swarm-manager1 Ready
   161  35o6tiywb700jesrt3dmllaza: swarm-worker1 Needs Rotation  
   162  ```
   163  
   164  
   165  ## Related commands
   166  
   167  * [node demote](node_demote.md)
   168  * [node inspect](node_inspect.md)
   169  * [node promote](node_promote.md)
   170  * [node ps](node_ps.md)
   171  * [node rm](node_rm.md)
   172  * [node update](node_update.md)