github.com/panekj/cli@v0.0.0-20230304125325-467dd2f3797e/docs/reference/commandline/node_ps.md (about)

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