github.com/thajeztah/cli@v0.0.0-20240223162942-dc6bfac81a8b/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
    48  more than one filter, then pass multiple flags (e.g., `--filter "foo=bar"
    49  --filter "bif=baz"`).
    50  
    51  The currently supported filters are:
    52  
    53  * [name](#name)
    54  * [id](#id)
    55  * [label](#label)
    56  * [desired-state](#desired-state)
    57  
    58  #### name
    59  
    60  The `name` filter matches on all or part of a task's name.
    61  
    62  The 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  
    67  NAME                                IMAGE        NODE            DESIRED STATE  CURRENT STATE
    68  redis.1.7q92v0nr1hcgts2amcjyqg3pq   redis:3.0.6  swarm-manager1  Running        Running 5 hours
    69  redis.6.b465edgho06e318egmgjbqo4o   redis:3.0.6  swarm-manager1  Running        Running 29 seconds
    70  redis.7.bg8c07zzg87di2mufeq51a2qp   redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    71  redis.9.dkkual96p4bb3s6b10r7coxxt   redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    72  redis.10.0tgctg8h8cech4w0k0gwrmr23  redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    73  ```
    74  
    75  #### id
    76  
    77  The `id` filter matches a task's id.
    78  
    79  ```console
    80  $ docker node ps -f id=bg8c07zzg87di2mufeq51a2qp swarm-manager1
    81  
    82  NAME                                IMAGE        NODE            DESIRED STATE  CURRENT STATE
    83  redis.7.bg8c07zzg87di2mufeq51a2qp   redis:3.0.6  swarm-manager1  Running        Running 5 seconds
    84  ```
    85  
    86  #### label
    87  
    88  The `label` filter matches tasks based on the presence of a `label` alone or a `label` and a
    89  value.
    90  
    91  The following filter matches tasks with the `usage` label regardless of its value.
    92  
    93  ```console
    94  $ docker node ps -f "label=usage"
    95  
    96  NAME                               IMAGE        NODE            DESIRED STATE  CURRENT STATE
    97  redis.6.b465edgho06e318egmgjbqo4o  redis:3.0.6  swarm-manager1  Running        Running 10 minutes
    98  redis.7.bg8c07zzg87di2mufeq51a2qp  redis:3.0.6  swarm-manager1  Running        Running 9 minutes
    99  ```
   100  
   101  
   102  #### desired-state
   103  
   104  The `desired-state` filter can take the values `running`, `shutdown`, or `accepted`.
   105  
   106  
   107  ### <a name="format"></a> Format the output (--format)
   108  
   109  The formatting options (`--format`) pretty-prints tasks output
   110  using a Go template.
   111  
   112  Valid 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  
   125  When using the `--format` option, the `node ps` command will either
   126  output the data exactly as the template declares or, when using the
   127  `table` directive, includes column headers as well.
   128  
   129  The 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  
   135  top.1: busybox
   136  top.2: busybox
   137  top.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)