...

Text file src/github.com/docker/cli/docs/reference/commandline/node_ps.md

Documentation: github.com/docker/cli/docs/reference/commandline

     1# node ps
     2
     3<!---MARKER_GEN_START-->
     4List tasks running on one or more nodes, defaults to current node
     5
     6### Options
     7
     8| Name                                   | Type     | Default | Description                                |
     9|:---------------------------------------|:---------|:--------|:-------------------------------------------|
    10| [`-f`](#filter), [`--filter`](#filter) | `filter` |         | Filter output based on conditions provided |
    11| [`--format`](#format)                  | `string` |         | Pretty-print tasks using a Go template     |
    12| `--no-resolve`                         |          |         | Do not map IDs to Names                    |
    13| `--no-trunc`                           |          |         | Do not truncate output                     |
    14| `-q`, `--quiet`                        |          |         | Only display task IDs                      |
    15
    16
    17<!---MARKER_GEN_END-->
    18
    19## Description
    20
    21Lists all the tasks on a Node that Docker knows about. You can filter using the
    22`-f` or `--filter` flag. Refer to the [filtering](#filter) section for more
    23information about available filter options.
    24
    25> **Note**
    26>
    27> This is a cluster management command, and must be executed on a swarm
    28> manager node. To learn about managers and workers, refer to the
    29> [Swarm mode section](https://docs.docker.com/engine/swarm/) in the
    30> documentation.
    31
    32## Examples
    33
    34```console
    35$ docker node ps swarm-manager1
    36
    37NAME                                IMAGE        NODE            DESIRED STATE  CURRENT STATE
    38redis.1.7q92v0nr1hcgts2amcjyqg3pq   redis:3.0.6  swarm-manager1  Running        Running 5 hours
    39redis.6.b465edgho06e318egmgjbqo4o   redis:3.0.6  swarm-manager1  Running        Running 29 seconds
    40redis.7.bg8c07zzg87di2mufeq51a2qp   redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    41redis.9.dkkual96p4bb3s6b10r7coxxt   redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    42redis.10.0tgctg8h8cech4w0k0gwrmr23  redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    43```
    44
    45### <a name="filter"></a> Filtering (--filter)
    46
    47The filtering flag (`-f` or `--filter`) format is of "key=value". If there is
    48more than one filter, then pass multiple flags (e.g., `--filter "foo=bar"
    49--filter "bif=baz"`).
    50
    51The currently supported filters are:
    52
    53* [name](#name)
    54* [id](#id)
    55* [label](#label)
    56* [desired-state](#desired-state)
    57
    58#### name
    59
    60The `name` filter matches on all or part of a task's name.
    61
    62The following filter matches all tasks with a name containing the `redis` string.
    63
    64```console
    65$ docker node ps -f name=redis swarm-manager1
    66
    67NAME                                IMAGE        NODE            DESIRED STATE  CURRENT STATE
    68redis.1.7q92v0nr1hcgts2amcjyqg3pq   redis:3.0.6  swarm-manager1  Running        Running 5 hours
    69redis.6.b465edgho06e318egmgjbqo4o   redis:3.0.6  swarm-manager1  Running        Running 29 seconds
    70redis.7.bg8c07zzg87di2mufeq51a2qp   redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    71redis.9.dkkual96p4bb3s6b10r7coxxt   redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    72redis.10.0tgctg8h8cech4w0k0gwrmr23  redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    73```
    74
    75#### id
    76
    77The `id` filter matches a task's id.
    78
    79```console
    80$ docker node ps -f id=bg8c07zzg87di2mufeq51a2qp swarm-manager1
    81
    82NAME                                IMAGE        NODE            DESIRED STATE  CURRENT STATE
    83redis.7.bg8c07zzg87di2mufeq51a2qp   redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    84```
    85
    86#### label
    87
    88The `label` filter matches tasks based on the presence of a `label` alone or a `label` and a
    89value.
    90
    91The following filter matches tasks with the `usage` label regardless of its value.
    92
    93```console
    94$ docker node ps -f "label=usage"
    95
    96NAME                               IMAGE        NODE            DESIRED STATE  CURRENT STATE
    97redis.6.b465edgho06e318egmgjbqo4o  redis:3.0.6  swarm-manager1  Running        Running 10 minutes
    98redis.7.bg8c07zzg87di2mufeq51a2qp  redis:3.0.6  swarm-manager1  Running        Running 9 minutes
    99```
   100
   101
   102#### desired-state
   103
   104The `desired-state` filter can take the values `running`, `shutdown`, or `accepted`.
   105
   106
   107### <a name="format"></a> Format the output (--format)
   108
   109The formatting options (`--format`) pretty-prints tasks output
   110using a Go template.
   111
   112Valid placeholders for the Go template are listed below:
   113
   114| Placeholder     | Description                                                      |
   115|-----------------|------------------------------------------------------------------|
   116| `.ID`           | Task ID                                                          |
   117| `.Name`         | Task name                                                        |
   118| `.Image`        | Task image                                                       |
   119| `.Node`         | Node ID                                                          |
   120| `.DesiredState` | Desired state of the task (`running`, `shutdown`, or `accepted`) |
   121| `.CurrentState` | Current state of the task                                        |
   122| `.Error`        | Error                                                            |
   123| `.Ports`        | Task published ports                                             |
   124
   125When using the `--format` option, the `node ps` command will either
   126output the data exactly as the template declares or, when using the
   127`table` directive, includes column headers as well.
   128
   129The following example uses a template without headers and outputs the
   130`Name` and `Image` entries separated by a colon (`:`) for all tasks:
   131
   132```console
   133$ docker node ps --format "{{.Name}}: {{.Image}}"
   134
   135top.1: busybox
   136top.2: busybox
   137top.3: busybox
   138```
   139
   140## Related commands
   141
   142* [node demote](node_demote.md)
   143* [node inspect](node_inspect.md)
   144* [node ls](node_ls.md)
   145* [node promote](node_promote.md)
   146* [node rm](node_rm.md)
   147* [node update](node_update.md)

View as plain text