2016-10-14 18:30:36 -04:00
---
title: "node ls"
description: "The node ls command description and usage"
2016-11-03 18:48:30 -04:00
keywords: "node, list"
2016-10-14 18:30:36 -04:00
---
2016-06-13 22:57:19 -04:00
2017-10-04 13:03:55 -04:00
<!-- This file is maintained within the docker/cli GitHub
2017-07-28 13:28:23 -04:00
repository at https://github.com/docker/cli/. Make all
2016-10-19 13:25:45 -04:00
pull requests against that repo. If you see this file in
another repository, consider it read-only there, as it will
periodically be overwritten by the definitive file. Pull
requests which include edits to this file in other repositories
will be rejected.
-->
2016-06-13 22:57:19 -04:00
# node ls
2016-07-07 14:43:18 -04:00
```markdown
Usage: docker node ls [OPTIONS]
2016-06-13 22:57:19 -04:00
2016-07-07 14:43:18 -04:00
List nodes in the swarm
2016-06-13 22:57:19 -04:00
2016-07-07 14:43:18 -04:00
Aliases:
ls, list
2016-06-13 22:57:19 -04:00
2016-07-07 14:43:18 -04:00
Options:
2017-01-24 16:17:40 -05:00
-f, --filter filter Filter output based on conditions provided
--format string Pretty-print nodes using a Go template
--help Print usage
-q, --quiet Only display IDs
2016-07-07 14:43:18 -04:00
```
2016-06-13 22:57:19 -04:00
2017-02-07 18:42:48 -05:00
## Description
2016-06-13 22:57:19 -04:00
2017-02-07 18:42:48 -05:00
Lists all the nodes that the Docker Swarm manager knows about. You can filter
using the `-f` or `--filter` flag. Refer to the [filtering ](#filtering ) section
for more information about available filter options.
## Examples
2016-06-13 22:57:19 -04:00
2016-07-22 07:13:30 -04:00
```bash
$ docker node ls
2016-06-13 22:57:19 -04:00
2016-07-22 07:13:30 -04:00
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
1bcef6utixb0l0ca7gxuivsj0 swarm-worker2 Ready Active
38ciaotwjuritcdtn9npbnkuz swarm-worker1 Ready Active
e216jshn25ckzbvmwlnh5jr3g * swarm-manager1 Ready Active Leader
```
2017-03-08 13:29:15 -05:00
> **Note**:
> In the above example output, there is a hidden column of `.Self` that indicates if the
> node is the same node as the current docker daemon. A `*` (e.g., `e216jshn25ckzbvmwlnh5jr3g *`)
> means this node is the current docker daemon.
2017-01-24 16:17:40 -05:00
2016-06-13 22:57:19 -04:00
2017-02-07 18:42:48 -05:00
### Filtering
2016-06-13 22:57:19 -04:00
The filtering flag (`-f` or `--filter` ) format is of "key=value". If there is more
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"` )
The currently supported filters are:
2016-11-08 23:06:00 -05:00
* [id ](node_ls.md#id )
* [label ](node_ls.md#label )
* [membership ](node_ls.md#membership )
* [name ](node_ls.md#name )
* [role ](node_ls.md#role )
2016-06-13 22:57:19 -04:00
2017-02-07 18:42:48 -05:00
#### id
2016-06-13 22:57:19 -04:00
2016-11-08 23:06:00 -05:00
The `id` filter matches all or part of a node's id.
2016-06-13 22:57:19 -04:00
2016-07-22 07:13:30 -04:00
```bash
2016-11-08 23:06:00 -05:00
$ docker node ls -f id=1
2016-07-22 07:13:30 -04:00
2016-11-08 23:06:00 -05:00
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
1bcef6utixb0l0ca7gxuivsj0 swarm-worker2 Ready Active
2016-07-22 07:13:30 -04:00
```
2016-06-13 22:57:19 -04:00
2017-02-07 18:42:48 -05:00
#### label
2016-06-13 22:57:19 -04:00
2016-11-08 23:06:00 -05:00
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.
The following filter matches nodes with the `foo` label regardless of its value.
2016-06-13 22:57:19 -04:00
2016-07-22 07:13:30 -04:00
```bash
2016-11-08 23:06:00 -05:00
$ docker node ls -f "label=foo"
2016-06-13 22:57:19 -04:00
2016-07-22 07:13:30 -04:00
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
1bcef6utixb0l0ca7gxuivsj0 swarm-worker2 Ready Active
```
2016-06-13 22:57:19 -04:00
2017-04-24 08:53:30 -04:00
#### membership
2016-06-13 22:57:19 -04:00
2016-11-08 23:06:00 -05:00
The `membership` filter matches nodes based on the presence of a `membership` and a value
`accepted` or `pending` .
2016-06-13 22:57:19 -04:00
2016-11-08 23:06:00 -05:00
The following filter matches nodes with the `membership` of `accepted` .
2016-06-13 22:57:19 -04:00
```bash
2016-11-08 23:06:00 -05:00
$ docker node ls -f "membership=accepted"
2016-07-22 07:13:30 -04:00
2016-11-08 23:06:00 -05:00
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
1bcef6utixb0l0ca7gxuivsj0 swarm-worker2 Ready Active
38ciaotwjuritcdtn9npbnkuz swarm-worker1 Ready Active
2016-06-13 22:57:19 -04:00
```
2017-02-07 18:42:48 -05:00
#### name
2016-11-08 23:06:00 -05:00
The `name` filter matches on all or part of a node hostname.
The following filter matches the nodes with a name equal to `swarm-master` string.
```bash
$ docker node ls -f name=swarm-manager1
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
e216jshn25ckzbvmwlnh5jr3g * swarm-manager1 Ready Active Leader
```
2017-02-07 18:42:48 -05:00
#### role
2016-11-08 23:06:00 -05:00
The `role` filter matches nodes based on the presence of a `role` and a value `worker` or `manager` .
The following filter matches nodes with the `manager` role.
```bash
$ docker node ls -f "role=manager"
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
e216jshn25ckzbvmwlnh5jr3g * swarm-manager1 Ready Active Leader
```
2016-06-13 22:57:19 -04:00
2017-01-24 16:17:40 -05:00
### Formatting
The formatting options (`--format`) pretty-prints nodes output
using a Go template.
Valid placeholders for the Go template are listed below:
Placeholder | Description
-----------------|------------------------------------------------------------------------------------------
`.ID` | Node ID
2017-03-08 13:29:15 -05:00
`.Self` | Node of the daemon (`true/false`, `true` indicates that the node is the same as current docker daemon)
2017-01-24 16:17:40 -05:00
`.Hostname` | Node hostname
`.Status` | Node status
`.Availability` | Node availability ("active", "pause", or "drain")
`.ManagerStatus` | Manager status of the node
2017-05-10 16:32:47 -04:00
`.TLSStatus` | TLS status of the node ("Ready", or "Needs Rotation" has TLS certificate signed by an old CA)
2018-01-29 16:44:26 -05:00
`.EngineVersion` | Engine version
2017-01-24 16:17:40 -05:00
When using the `--format` option, the `node ls` command will either
output the data exactly as the template declares or, when using the
`table` directive, includes column headers as well.
The following example uses a template without headers and outputs the
2017-05-10 16:32:47 -04:00
`ID` , `Hostname` , and `TLS Status` entries separated by a colon for all nodes:
2017-01-24 16:17:40 -05:00
```bash
2017-05-10 16:32:47 -04:00
$ docker node ls --format "{{.ID}}: {{.Hostname}} {{.TLSStatus}}"
e216jshn25ckzbvmwlnh5jr3g: swarm-manager1 Ready
35o6tiywb700jesrt3dmllaza: swarm-worker1 Needs Rotation
2017-08-01 00:33:07 -04:00
```
2017-01-24 16:17:40 -05:00
2017-02-07 18:42:48 -05:00
## Related commands
2016-06-13 22:57:19 -04:00
2016-12-13 09:15:08 -05:00
* [node demote ](node_demote.md )
2016-06-13 22:57:19 -04:00
* [node inspect ](node_inspect.md )
2016-12-13 09:15:08 -05:00
* [node promote ](node_promote.md )
2016-07-19 17:01:31 -04:00
* [node ps ](node_ps.md )
2016-06-13 22:57:19 -04:00
* [node rm ](node_rm.md )
2016-12-13 09:15:08 -05:00
* [node update ](node_update.md )