github.com/kaisenlinux/docker.io@v0.0.0-20230510090727-ea55db55fac7/cli/docs/reference/commandline/node_ps.md (about)

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