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