github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/stack_ps.md (about)

     1  ---
     2  title: "stack ps"
     3  description: "The stack ps command description and usage"
     4  keywords: "stack, ps"
     5  ---
     6  
     7  <!-- This file is maintained within the docker/cli GitHub
     8       repository at https://github.com/docker/cli/. Make all
     9       pull requests against that repo. If you see this file in
    10       another repository, consider it read-only there, as it will
    11       periodically be overwritten by the definitive file. Pull
    12       requests which include edits to this file in other repositories
    13       will be rejected.
    14  -->
    15  
    16  # stack ps
    17  
    18  ```markdown
    19  Usage:  docker stack ps [OPTIONS] STACK
    20  
    21  List the tasks in the stack
    22  
    23  Options:
    24    -f, --filter filter         Filter output based on conditions provided
    25        --format string         Pretty-print tasks using a Go template
    26        --help                  Print usage
    27        --kubeconfig string     Kubernetes config file
    28        --namespace string      Kubernetes namespace to use
    29        --no-resolve            Do not map IDs to Names
    30        --no-trunc              Do not truncate output
    31        --orchestrator string   Orchestrator to use (swarm|kubernetes|all)
    32    -q, --quiet                 Only display task IDs
    33  ```
    34  
    35  ## Description
    36  
    37  Lists the tasks that are running as part of the specified stack. This
    38  command has to be run targeting a manager node.
    39  
    40  ## Examples
    41  
    42  ### List the tasks that are part of a stack
    43  
    44  The following command shows all the tasks that are part of the `voting` stack:
    45  
    46  ```bash
    47  $ docker stack ps voting
    48  ID                  NAME                  IMAGE                                          NODE   DESIRED STATE  CURRENT STATE          ERROR  PORTS
    49  xim5bcqtgk1b        voting_worker.1       dockersamples/examplevotingapp_worker:latest   node2  Running        Running 2 minutes ago
    50  q7yik0ks1in6        voting_result.1       dockersamples/examplevotingapp_result:before   node1  Running        Running 2 minutes ago
    51  rx5yo0866nfx        voting_vote.1         dockersamples/examplevotingapp_vote:before     node3  Running        Running 2 minutes ago
    52  tz6j82jnwrx7        voting_db.1           postgres:9.4                                   node1  Running        Running 2 minutes ago
    53  w48spazhbmxc        voting_redis.1        redis:alpine                                   node2  Running        Running 3 minutes ago
    54  6jj1m02freg1        voting_visualizer.1   dockersamples/visualizer:stable                node1  Running        Running 2 minutes ago
    55  kqgdmededccb        voting_vote.2         dockersamples/examplevotingapp_vote:before     node2  Running        Running 2 minutes ago
    56  t72q3z038jeh        voting_redis.2        redis:alpine                                   node3  Running        Running 3 minutes ago
    57  ```
    58  
    59  ### Filtering
    60  
    61  The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
    62  is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
    63  Multiple filter flags are combined as an `OR` filter. For example,
    64  `-f name=redis.1 -f name=redis.7` returns both `redis.1` and `redis.7` tasks.
    65  
    66  The currently supported filters are:
    67  
    68  * [id](#id)
    69  * [name](#name)
    70  * [node](#node)
    71  * [desired-state](#desired-state)
    72  
    73  #### id
    74  
    75  The `id` filter matches on all or a prefix of a task's ID.
    76  
    77  ```bash
    78  $ docker stack ps -f "id=t" voting
    79  ID                  NAME                IMAGE               NODE         DESIRED STATE       CURRENTSTATE            ERROR  PORTS
    80  tz6j82jnwrx7        voting_db.1         postgres:9.4        node1        Running             Running 14 minutes ago
    81  t72q3z038jeh        voting_redis.2      redis:alpine        node3        Running             Running 14 minutes ago
    82  ```
    83  
    84  #### name
    85  
    86  The `name` filter matches on task names.
    87  
    88  ```bash
    89  $ docker stack ps -f "name=voting_redis" voting
    90  ID                  NAME                IMAGE               NODE         DESIRED STATE       CURRENTSTATE            ERROR  PORTS
    91  w48spazhbmxc        voting_redis.1      redis:alpine        node2        Running             Running 17 minutes ago
    92  t72q3z038jeh        voting_redis.2      redis:alpine        node3        Running             Running 17 minutes ago
    93  ```
    94  
    95  #### node
    96  
    97  The `node` filter matches on a node name or a node ID.
    98  
    99  ```bash
   100  $ docker stack ps -f "node=node1" voting
   101  ID                  NAME                  IMAGE                                          NODE   DESIRED STATE  CURRENT STATE          ERROR  PORTS
   102  q7yik0ks1in6        voting_result.1       dockersamples/examplevotingapp_result:before   node1  Running        Running 18 minutes ago
   103  tz6j82jnwrx7        voting_db.1           postgres:9.4                                   node1  Running        Running 18 minutes ago
   104  6jj1m02freg1        voting_visualizer.1   dockersamples/visualizer:stable                node1  Running        Running 18 minutes ago
   105  ```
   106  
   107  #### desired-state
   108  
   109  The `desired-state` filter can take the values `running`, `shutdown`, or `accepted`.
   110  
   111  ```bash
   112  $ docker stack ps -f "desired-state=running" voting
   113  ID                  NAME                  IMAGE                                          NODE   DESIRED STATE  CURRENT STATE           ERROR  PORTS
   114  xim5bcqtgk1b        voting_worker.1       dockersamples/examplevotingapp_worker:latest   node2  Running        Running 21 minutes ago
   115  q7yik0ks1in6        voting_result.1       dockersamples/examplevotingapp_result:before   node1  Running        Running 21 minutes ago
   116  rx5yo0866nfx        voting_vote.1         dockersamples/examplevotingapp_vote:before     node3  Running        Running 21 minutes ago
   117  tz6j82jnwrx7        voting_db.1           postgres:9.4                                   node1  Running        Running 21 minutes ago
   118  w48spazhbmxc        voting_redis.1        redis:alpine                                   node2  Running        Running 21 minutes ago
   119  6jj1m02freg1        voting_visualizer.1   dockersamples/visualizer:stable                node1  Running        Running 21 minutes ago
   120  kqgdmededccb        voting_vote.2         dockersamples/examplevotingapp_vote:before     node2  Running        Running 21 minutes ago
   121  t72q3z038jeh        voting_redis.2        redis:alpine                                   node3  Running        Running 21 minutes ago
   122  ```
   123  
   124  ### Formatting
   125  
   126  The formatting options (`--format`) pretty-prints tasks output using a Go template.
   127  
   128  Valid placeholders for the Go template are listed below:
   129  
   130  Placeholder     | Description
   131  ----------------|------------------------------------------------------------------------------------------
   132  `.ID`           | Task ID
   133  `.Name`         | Task name
   134  `.Image`        | Task image
   135  `.Node`         | Node ID
   136  `.DesiredState` | Desired state of the task (`running`, `shutdown`, or `accepted`)
   137  `.CurrentState` | Current state of the task
   138  `.Error`        | Error
   139  `.Ports`        | Task published ports
   140  
   141  When using the `--format` option, the `stack ps` command will either
   142  output the data exactly as the template declares or, when using the
   143  `table` directive, includes column headers as well.
   144  
   145  The following example uses a template without headers and outputs the
   146  `Name` and `Image` entries separated by a colon for all tasks:
   147  
   148  ```bash
   149  $ docker stack ps --format "{{.Name}}: {{.Image}}" voting
   150  voting_worker.1: dockersamples/examplevotingapp_worker:latest
   151  voting_result.1: dockersamples/examplevotingapp_result:before
   152  voting_vote.1: dockersamples/examplevotingapp_vote:before
   153  voting_db.1: postgres:9.4
   154  voting_redis.1: redis:alpine
   155  voting_visualizer.1: dockersamples/visualizer:stable
   156  voting_vote.2: dockersamples/examplevotingapp_vote:before
   157  voting_redis.2: redis:alpine
   158  ```
   159  
   160  ### Do not map IDs to Names
   161  
   162  The `--no-resolve` option shows IDs for task name, without mapping IDs to Names.
   163  
   164  ```bash
   165  $ docker stack ps --no-resolve voting
   166  ID                  NAME                          IMAGE                                          NODE                        DESIRED STATE  CURRENT STATE            ERROR  PORTS
   167  xim5bcqtgk1b        10z9fjfqzsxnezo4hb81p8mqg.1   dockersamples/examplevotingapp_worker:latest   qaqt4nrzo775jrx6detglho01   Running        Running 30 minutes ago
   168  q7yik0ks1in6        hbxltua1na7mgqjnidldv5m65.1   dockersamples/examplevotingapp_result:before   mxpaef1tlh23s052erw88a4w5   Running        Running 30 minutes ago
   169  rx5yo0866nfx        qyprtqw1g5nrki557i974ou1d.1   dockersamples/examplevotingapp_vote:before     kanqcxfajd1r16wlnqcblobmm   Running        Running 31 minutes ago
   170  tz6j82jnwrx7        122f0xxngg17z52be7xspa72x.1   postgres:9.4                                   mxpaef1tlh23s052erw88a4w5   Running        Running 31 minutes ago
   171  w48spazhbmxc        tg61x8myx563ueo3urmn1ic6m.1   redis:alpine                                   qaqt4nrzo775jrx6detglho01   Running        Running 31 minutes ago
   172  6jj1m02freg1        8cqlyi444kzd3panjb7edh26v.1   dockersamples/visualizer:stable                mxpaef1tlh23s052erw88a4w5   Running        Running 31 minutes ago
   173  kqgdmededccb        qyprtqw1g5nrki557i974ou1d.2   dockersamples/examplevotingapp_vote:before     qaqt4nrzo775jrx6detglho01   Running        Running 31 minutes ago
   174  t72q3z038jeh        tg61x8myx563ueo3urmn1ic6m.2   redis:alpine                                   kanqcxfajd1r16wlnqcblobmm   Running        Running 31 minutes ago
   175  ```
   176  
   177  ### Do not truncate output
   178  
   179  When deploying a service, docker resolves the digest for the service's
   180  image, and pins the service to that digest. The digest is not shown by
   181  default, but is printed if `--no-trunc` is used. The `--no-trunc` option
   182  also shows the non-truncated task IDs, and error-messages, as can be seen below:
   183  
   184  ```bash
   185  $ docker stack ps --no-trunc voting
   186  ID                          NAME                  IMAGE                                                                                                                 NODE   DESIRED STATE  CURREN STATE           ERROR  PORTS
   187  xim5bcqtgk1bxqz91jzo4a1s5   voting_worker.1       dockersamples/examplevotingapp_worker:latest@sha256:3e4ddf59c15f432280a2c0679c4fc5a2ee5a797023c8ef0d3baf7b1385e9fed   node2  Running        Runnin 32 minutes ago
   188  q7yik0ks1in6kv32gg6y6yjf7   voting_result.1       dockersamples/examplevotingapp_result:before@sha256:83b56996e930c292a6ae5187fda84dd6568a19d97cdb933720be15c757b7463   node1  Running        Runnin 32 minutes ago
   189  rx5yo0866nfxc58zf4irsss6n   voting_vote.1         dockersamples/examplevotingapp_vote:before@sha256:8e64b182c87de902f2b72321c89b4af4e2b942d76d0b772532ff27ec4c6ebf6     node3  Running        Runnin 32 minutes ago
   190  tz6j82jnwrx7n2offljp3mn03   voting_db.1           postgres:9.4@sha256:6046af499eae34d2074c0b53f9a8b404716d415e4a03e68bc1d2f8064f2b027                                   node1  Running        Runnin 32 minutes ago
   191  w48spazhbmxcmbjfi54gs7x90   voting_redis.1        redis:alpine@sha256:9cd405cd1ec1410eaab064a1383d0d8854d1ef74a54e1e4a92fb4ec7bdc3ee7                                   node2  Running        Runnin 32 minutes ago
   192  6jj1m02freg1n3z9n1evrzsbl   voting_visualizer.1   dockersamples/visualizer:stable@sha256:f924ad66c8e94b10baaf7bdb9cd491ef4e982a1d048a56a17e02bf5945401e5                node1  Running        Runnin 32 minutes ago
   193  kqgdmededccbhz2wuc0e9hx7g   voting_vote.2         dockersamples/examplevotingapp_vote:before@sha256:8e64b182c87de902f2b72321c89b4af4e2b942d76d0b772532ff27ec4c6ebf6     node2  Running        Runnin 32 minutes ago
   194  t72q3z038jehe1wbh9gdum076   voting_redis.2        redis:alpine@sha256:9cd405cd1ec1410eaab064a1383d0d8854d1ef74a54e1e4a92fb4ec7bdc3ee7                                   node3  Running        Runnin 32 minutes ago
   195  ```
   196  
   197  ### Only display task IDs
   198  
   199  The `-q ` or `--quiet` option only shows IDs of the tasks in the stack.
   200  This example outputs all task IDs of the "voting" stack;
   201  
   202  ```bash
   203  $ docker stack ps -q voting
   204  xim5bcqtgk1b
   205  q7yik0ks1in6
   206  rx5yo0866nfx
   207  tz6j82jnwrx7
   208  w48spazhbmxc
   209  6jj1m02freg1
   210  kqgdmededccb
   211  t72q3z038jeh
   212  ```
   213  
   214  This option can be used to perform batch operations. For example, you can use
   215  the task IDs as input for other commands, such as `docker inspect`. The
   216  following example inspects all tasks of the "voting" stack;
   217  
   218  ```bash
   219  $ docker inspect $(docker stack ps -q voting)
   220  
   221  [
   222      {
   223          "ID": "xim5bcqtgk1b1gk0krq1",
   224          "Version": {
   225  (...)
   226  ```
   227  
   228  ## Related commands
   229  
   230  * [stack deploy](stack_deploy.md)
   231  * [stack ls](stack_ls.md)
   232  * [stack rm](stack_rm.md)
   233  * [stack services](stack_services.md)