2016-07-19 17:01:31 -04:00
|
|
|
# node ps
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2023-01-06 13:04:05 -05:00
|
|
|
<!---MARKER_GEN_START-->
|
|
|
|
List tasks running on one or more nodes, defaults to current node
|
|
|
|
|
|
|
|
### Options
|
|
|
|
|
|
|
|
| Name | Type | Default | Description |
|
|
|
|
|:---------------------------------------|:---------|:--------|:-------------------------------------------|
|
|
|
|
| [`-f`](#filter), [`--filter`](#filter) | `filter` | | Filter output based on conditions provided |
|
|
|
|
| [`--format`](#format) | `string` | | Pretty-print tasks using a Go template |
|
2024-07-03 02:29:57 -04:00
|
|
|
| `--no-resolve` | `bool` | | Do not map IDs to Names |
|
|
|
|
| `--no-trunc` | `bool` | | Do not truncate output |
|
|
|
|
| `-q`, `--quiet` | `bool` | | Only display task IDs |
|
2016-06-13 22:57:19 -04:00
|
|
|
|
|
|
|
|
2023-01-06 13:04:05 -05:00
|
|
|
<!---MARKER_GEN_END-->
|
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
|
|
|
|
2018-12-23 06:27:52 -05:00
|
|
|
Lists all the tasks on a Node that Docker knows about. You can filter using the
|
2023-01-06 12:05:02 -05:00
|
|
|
`-f` or `--filter` flag. Refer to the [filtering](#filter) section for more
|
2018-12-23 06:27:52 -05:00
|
|
|
information about available filter options.
|
|
|
|
|
2024-08-16 05:02:10 -04:00
|
|
|
> [!NOTE]
|
2020-04-19 11:08:37 -04:00
|
|
|
> This is a cluster management command, and must be executed on a swarm
|
|
|
|
> manager node. To learn about managers and workers, refer to the
|
|
|
|
> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
|
|
|
|
> documentation.
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Examples
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2017-02-07 18:42:48 -05:00
|
|
|
$ docker node ps swarm-manager1
|
2021-08-21 08:54:14 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
2024-11-05 05:20:17 -05:00
|
|
|
redis.1.7q92v0nr1hcgts2amcjyqg3pq redis:7.4.1 swarm-manager1 Running Running 5 hours
|
|
|
|
redis.6.b465edgho06e318egmgjbqo4o redis:7.4.1 swarm-manager1 Running Running 29 seconds
|
|
|
|
redis.7.bg8c07zzg87di2mufeq51a2qp redis:7.4.1 swarm-manager1 Running Running 5 seconds
|
|
|
|
redis.9.dkkual96p4bb3s6b10r7coxxt redis:7.4.1 swarm-manager1 Running Running 5 seconds
|
|
|
|
redis.10.0tgctg8h8cech4w0k0gwrmr23 redis:7.4.1 swarm-manager1 Running Running 5 seconds
|
2017-02-07 18:42:48 -05:00
|
|
|
```
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2023-01-06 13:28:29 -05:00
|
|
|
### <a name="filter"></a> Filtering (--filter)
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2023-12-13 18:06:16 -05: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"`).
|
2016-06-13 22:57:19 -04:00
|
|
|
|
|
|
|
The currently supported filters are:
|
|
|
|
|
2016-06-29 10:16:31 -04:00
|
|
|
* [name](#name)
|
|
|
|
* [id](#id)
|
|
|
|
* [label](#label)
|
2016-06-29 12:20:32 -04:00
|
|
|
* [desired-state](#desired-state)
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2016-06-29 10:16:31 -04:00
|
|
|
#### name
|
2016-06-13 22:57:19 -04:00
|
|
|
|
|
|
|
The `name` filter matches on all or part of a task's name.
|
|
|
|
|
|
|
|
The following filter matches all tasks with a name containing the `redis` string.
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2017-02-07 18:42:48 -05:00
|
|
|
$ docker node ps -f name=redis swarm-manager1
|
|
|
|
|
|
|
|
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
2024-11-05 05:20:17 -05:00
|
|
|
redis.1.7q92v0nr1hcgts2amcjyqg3pq redis:7.4.1 swarm-manager1 Running Running 5 hours
|
|
|
|
redis.6.b465edgho06e318egmgjbqo4o redis:7.4.1 swarm-manager1 Running Running 29 seconds
|
|
|
|
redis.7.bg8c07zzg87di2mufeq51a2qp redis:7.4.1 swarm-manager1 Running Running 5 seconds
|
|
|
|
redis.9.dkkual96p4bb3s6b10r7coxxt redis:7.4.1 swarm-manager1 Running Running 5 seconds
|
|
|
|
redis.10.0tgctg8h8cech4w0k0gwrmr23 redis:7.4.1 swarm-manager1 Running Running 5 seconds
|
2017-02-07 18:42:48 -05:00
|
|
|
```
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2016-06-29 10:16:31 -04:00
|
|
|
#### id
|
2016-06-13 22:57:19 -04:00
|
|
|
|
|
|
|
The `id` filter matches a task's id.
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2017-02-07 18:42:48 -05:00
|
|
|
$ docker node ps -f id=bg8c07zzg87di2mufeq51a2qp swarm-manager1
|
2016-06-13 22:57:19 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
2024-11-05 05:20:17 -05:00
|
|
|
redis.7.bg8c07zzg87di2mufeq51a2qp redis:7.4.1 swarm-manager1 Running Running 5 seconds
|
2017-02-07 18:42:48 -05:00
|
|
|
```
|
2016-06-13 22:57:19 -04:00
|
|
|
|
|
|
|
#### label
|
|
|
|
|
|
|
|
The `label` filter matches tasks based on the presence of a `label` alone or a `label` and a
|
|
|
|
value.
|
|
|
|
|
|
|
|
The following filter matches tasks with the `usage` label regardless of its value.
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-07-19 17:01:31 -04:00
|
|
|
$ docker node ps -f "label=usage"
|
2017-02-07 18:42:48 -05:00
|
|
|
|
2016-09-27 22:12:48 -04:00
|
|
|
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
2024-11-05 05:20:17 -05:00
|
|
|
redis.6.b465edgho06e318egmgjbqo4o redis:7.4.1 swarm-manager1 Running Running 10 minutes
|
|
|
|
redis.7.bg8c07zzg87di2mufeq51a2qp redis:7.4.1 swarm-manager1 Running Running 9 minutes
|
2016-06-13 22:57:19 -04:00
|
|
|
```
|
|
|
|
|
|
|
|
|
2016-06-29 12:20:32 -04:00
|
|
|
#### desired-state
|
2016-06-29 10:16:31 -04:00
|
|
|
|
2017-03-29 16:13:28 -04:00
|
|
|
The `desired-state` filter can take the values `running`, `shutdown`, or `accepted`.
|
2016-06-29 10:16:31 -04:00
|
|
|
|
|
|
|
|
2023-01-06 13:28:29 -05:00
|
|
|
### <a name="format"></a> Format the output (--format)
|
2016-11-07 00:54:40 -05:00
|
|
|
|
|
|
|
The formatting options (`--format`) pretty-prints tasks output
|
|
|
|
using a Go template.
|
|
|
|
|
|
|
|
Valid placeholders for the Go template are listed below:
|
|
|
|
|
2022-03-30 08:33:44 -04:00
|
|
|
| Placeholder | Description |
|
|
|
|
|-----------------|------------------------------------------------------------------|
|
|
|
|
| `.ID` | Task ID |
|
|
|
|
| `.Name` | Task name |
|
|
|
|
| `.Image` | Task image |
|
|
|
|
| `.Node` | Node ID |
|
|
|
|
| `.DesiredState` | Desired state of the task (`running`, `shutdown`, or `accepted`) |
|
|
|
|
| `.CurrentState` | Current state of the task |
|
|
|
|
| `.Error` | Error |
|
|
|
|
| `.Ports` | Task published ports |
|
2016-11-07 00:54:40 -05:00
|
|
|
|
|
|
|
When using the `--format` option, the `node ps` 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
|
2020-04-19 11:23:09 -04:00
|
|
|
`Name` and `Image` entries separated by a colon (`:`) for all tasks:
|
2016-11-07 00:54:40 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-11-07 00:54:40 -05:00
|
|
|
$ docker node ps --format "{{.Name}}: {{.Image}}"
|
2021-08-21 08:54:14 -04:00
|
|
|
|
2016-11-07 00:54:40 -05:00
|
|
|
top.1: busybox
|
|
|
|
top.2: busybox
|
|
|
|
top.3: busybox
|
|
|
|
```
|
|
|
|
|
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)
|
|
|
|
* [node ls](node_ls.md)
|
2016-12-13 09:15:08 -05:00
|
|
|
* [node promote](node_promote.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)
|