provide `docker stack ps` examples
| ... | ... |
@@ -104,7 +104,7 @@ redis.7.bg8c07zzg87di2mufeq51a2qp redis:3.0.6 swarm-manager1 Running R |
| 104 | 104 |
|
| 105 | 105 |
#### desired-state |
| 106 | 106 |
|
| 107 |
-The `desired-state` filter can take the values `running`, `shutdown`, and `accepted`. |
|
| 107 |
+The `desired-state` filter can take the values `running`, `shutdown`, or `accepted`. |
|
| 108 | 108 |
|
| 109 | 109 |
|
| 110 | 110 |
### Formatting |
| ... | ... |
@@ -119,7 +119,7 @@ Placeholder | Description |
| 119 | 119 |
`.Name` | Task name |
| 120 | 120 |
`.Image` | Task image |
| 121 | 121 |
`.Node` | Node ID |
| 122 |
-`.DesiredState` | Desired state of the task (`running`, `shutdown`, and `accepted`) |
|
| 122 |
+`.DesiredState` | Desired state of the task (`running`, `shutdown`, or `accepted`) |
|
| 123 | 123 |
`.CurrentState` | Current state of the task |
| 124 | 124 |
`.Error` | Error |
| 125 | 125 |
`.Ports` | Task published ports |
| ... | ... |
@@ -129,7 +129,7 @@ output the data exactly as the template declares or, when using the |
| 129 | 129 |
`table` directive, includes column headers as well. |
| 130 | 130 |
|
| 131 | 131 |
The following example uses a template without headers and outputs the |
| 132 |
-`ID` and `Driver` entries separated by a colon for all tasks: |
|
| 132 |
+`Name` and `Image` entries separated by a colon for all tasks: |
|
| 133 | 133 |
|
| 134 | 134 |
```bash |
| 135 | 135 |
$ docker node ps --format "{{.Name}}: {{.Image}}"
|
| ... | ... |
@@ -149,7 +149,7 @@ ID NAME IMAGE NODE DESIRED STATE CURRENT STATE |
| 149 | 149 |
|
| 150 | 150 |
#### desired-state |
| 151 | 151 |
|
| 152 |
-The `desired-state` filter can take the values `running`, `shutdown`, and `accepted`. |
|
| 152 |
+The `desired-state` filter can take the values `running`, `shutdown`, or `accepted`. |
|
| 153 | 153 |
|
| 154 | 154 |
### Formatting |
| 155 | 155 |
|
| ... | ... |
@@ -164,7 +164,7 @@ Placeholder | Description |
| 164 | 164 |
`.Name` | Task name |
| 165 | 165 |
`.Image` | Task image |
| 166 | 166 |
`.Node` | Node ID |
| 167 |
-`.DesiredState` | Desired state of the task (`running`, `shutdown`, and `accepted`) |
|
| 167 |
+`.DesiredState` | Desired state of the task (`running`, `shutdown`, or `accepted`) |
|
| 168 | 168 |
`.CurrentState` | Current state of the task |
| 169 | 169 |
`.Error` | Error |
| 170 | 170 |
`.Ports` | Task published ports |
| ... | ... |
@@ -36,8 +36,21 @@ command has to be run targeting a manager node. |
| 36 | 36 |
|
| 37 | 37 |
## Examples |
| 38 | 38 |
|
| 39 |
+### List the tasks that are part of a stack |
|
| 40 |
+ |
|
| 41 |
+The following command shows all the tasks that are part of the `voting` stack: |
|
| 42 |
+ |
|
| 39 | 43 |
```bash |
| 40 |
-$ docker stack ps |
|
| 44 |
+$ docker stack ps voting |
|
| 45 |
+ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS |
|
| 46 |
+xim5bcqtgk1b voting_worker.1 dockersamples/examplevotingapp_worker:latest node2 Running Running 2 minutes ago |
|
| 47 |
+q7yik0ks1in6 voting_result.1 dockersamples/examplevotingapp_result:before node1 Running Running 2 minutes ago |
|
| 48 |
+rx5yo0866nfx voting_vote.1 dockersamples/examplevotingapp_vote:before node3 Running Running 2 minutes ago |
|
| 49 |
+tz6j82jnwrx7 voting_db.1 postgres:9.4 node1 Running Running 2 minutes ago |
|
| 50 |
+w48spazhbmxc voting_redis.1 redis:alpine node2 Running Running 3 minutes ago |
|
| 51 |
+6jj1m02freg1 voting_visualizer.1 dockersamples/visualizer:stable node1 Running Running 2 minutes ago |
|
| 52 |
+kqgdmededccb voting_vote.2 dockersamples/examplevotingapp_vote:before node2 Running Running 2 minutes ago |
|
| 53 |
+t72q3z038jeh voting_redis.2 redis:alpine node3 Running Running 3 minutes ago |
|
| 41 | 54 |
``` |
| 42 | 55 |
|
| 43 | 56 |
### Filtering |
| ... | ... |
@@ -49,9 +62,165 @@ Multiple filter flags are combined as an `OR` filter. For example, |
| 49 | 49 |
|
| 50 | 50 |
The currently supported filters are: |
| 51 | 51 |
|
| 52 |
-* id |
|
| 53 |
-* name |
|
| 54 |
-* desired-state |
|
| 52 |
+* [id](#id) |
|
| 53 |
+* [name](#name) |
|
| 54 |
+* [node](#node) |
|
| 55 |
+* [desired-state](#desired-state) |
|
| 56 |
+ |
|
| 57 |
+#### id |
|
| 58 |
+ |
|
| 59 |
+The `id` filter matches on all or a prefix of a task's ID. |
|
| 60 |
+ |
|
| 61 |
+```bash |
|
| 62 |
+$ docker stack ps -f "id=t" voting |
|
| 63 |
+ID NAME IMAGE NODE DESIRED STATE CURRENTSTATE ERROR PORTS |
|
| 64 |
+tz6j82jnwrx7 voting_db.1 postgres:9.4 node1 Running Running 14 minutes ago |
|
| 65 |
+t72q3z038jeh voting_redis.2 redis:alpine node3 Running Running 14 minutes ago |
|
| 66 |
+``` |
|
| 67 |
+ |
|
| 68 |
+#### name |
|
| 69 |
+ |
|
| 70 |
+The `name` filter matches on task names. |
|
| 71 |
+ |
|
| 72 |
+```bash |
|
| 73 |
+$ docker stack ps -f "name=voting_redis" voting |
|
| 74 |
+ID NAME IMAGE NODE DESIRED STATE CURRENTSTATE ERROR PORTS |
|
| 75 |
+w48spazhbmxc voting_redis.1 redis:alpine node2 Running Running 17 minutes ago |
|
| 76 |
+t72q3z038jeh voting_redis.2 redis:alpine node3 Running Running 17 minutes ago |
|
| 77 |
+``` |
|
| 78 |
+ |
|
| 79 |
+#### node |
|
| 80 |
+ |
|
| 81 |
+The `node` filter matches on a node name or a node ID. |
|
| 82 |
+ |
|
| 83 |
+```bash |
|
| 84 |
+$ docker stack ps -f "node=node1" voting |
|
| 85 |
+ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS |
|
| 86 |
+q7yik0ks1in6 voting_result.1 dockersamples/examplevotingapp_result:before node1 Running Running 18 minutes ago |
|
| 87 |
+tz6j82jnwrx7 voting_db.1 postgres:9.4 node1 Running Running 18 minutes ago |
|
| 88 |
+6jj1m02freg1 voting_visualizer.1 dockersamples/visualizer:stable node1 Running Running 18 minutes ago |
|
| 89 |
+``` |
|
| 90 |
+ |
|
| 91 |
+#### desired-state |
|
| 92 |
+ |
|
| 93 |
+The `desired-state` filter can take the values `running`, `shutdown`, or `accepted`. |
|
| 94 |
+ |
|
| 95 |
+```bash |
|
| 96 |
+$ docker stack ps -f "desired-state=running" voting |
|
| 97 |
+ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS |
|
| 98 |
+xim5bcqtgk1b voting_worker.1 dockersamples/examplevotingapp_worker:latest node2 Running Running 21 minutes ago |
|
| 99 |
+q7yik0ks1in6 voting_result.1 dockersamples/examplevotingapp_result:before node1 Running Running 21 minutes ago |
|
| 100 |
+rx5yo0866nfx voting_vote.1 dockersamples/examplevotingapp_vote:before node3 Running Running 21 minutes ago |
|
| 101 |
+tz6j82jnwrx7 voting_db.1 postgres:9.4 node1 Running Running 21 minutes ago |
|
| 102 |
+w48spazhbmxc voting_redis.1 redis:alpine node2 Running Running 21 minutes ago |
|
| 103 |
+6jj1m02freg1 voting_visualizer.1 dockersamples/visualizer:stable node1 Running Running 21 minutes ago |
|
| 104 |
+kqgdmededccb voting_vote.2 dockersamples/examplevotingapp_vote:before node2 Running Running 21 minutes ago |
|
| 105 |
+t72q3z038jeh voting_redis.2 redis:alpine node3 Running Running 21 minutes ago |
|
| 106 |
+``` |
|
| 107 |
+ |
|
| 108 |
+### Formatting |
|
| 109 |
+ |
|
| 110 |
+The formatting options (`--format`) pretty-prints tasks output 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 `stack 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 |
+```bash |
|
| 133 |
+$ docker stack ps --format "{{.Name}}: {{.Image}}" voting
|
|
| 134 |
+voting_worker.1: dockersamples/examplevotingapp_worker:latest |
|
| 135 |
+voting_result.1: dockersamples/examplevotingapp_result:before |
|
| 136 |
+voting_vote.1: dockersamples/examplevotingapp_vote:before |
|
| 137 |
+voting_db.1: postgres:9.4 |
|
| 138 |
+voting_redis.1: redis:alpine |
|
| 139 |
+voting_visualizer.1: dockersamples/visualizer:stable |
|
| 140 |
+voting_vote.2: dockersamples/examplevotingapp_vote:before |
|
| 141 |
+voting_redis.2: redis:alpine |
|
| 142 |
+``` |
|
| 143 |
+ |
|
| 144 |
+### Do not map IDs to Names |
|
| 145 |
+ |
|
| 146 |
+The `--no-resolve` option shows IDs for task name, without mapping IDs to Names. |
|
| 147 |
+ |
|
| 148 |
+```bash |
|
| 149 |
+$ docker stack ps --no-resolve voting |
|
| 150 |
+ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS |
|
| 151 |
+xim5bcqtgk1b 10z9fjfqzsxnezo4hb81p8mqg.1 dockersamples/examplevotingapp_worker:latest qaqt4nrzo775jrx6detglho01 Running Running 30 minutes ago |
|
| 152 |
+q7yik0ks1in6 hbxltua1na7mgqjnidldv5m65.1 dockersamples/examplevotingapp_result:before mxpaef1tlh23s052erw88a4w5 Running Running 30 minutes ago |
|
| 153 |
+rx5yo0866nfx qyprtqw1g5nrki557i974ou1d.1 dockersamples/examplevotingapp_vote:before kanqcxfajd1r16wlnqcblobmm Running Running 31 minutes ago |
|
| 154 |
+tz6j82jnwrx7 122f0xxngg17z52be7xspa72x.1 postgres:9.4 mxpaef1tlh23s052erw88a4w5 Running Running 31 minutes ago |
|
| 155 |
+w48spazhbmxc tg61x8myx563ueo3urmn1ic6m.1 redis:alpine qaqt4nrzo775jrx6detglho01 Running Running 31 minutes ago |
|
| 156 |
+6jj1m02freg1 8cqlyi444kzd3panjb7edh26v.1 dockersamples/visualizer:stable mxpaef1tlh23s052erw88a4w5 Running Running 31 minutes ago |
|
| 157 |
+kqgdmededccb qyprtqw1g5nrki557i974ou1d.2 dockersamples/examplevotingapp_vote:before qaqt4nrzo775jrx6detglho01 Running Running 31 minutes ago |
|
| 158 |
+t72q3z038jeh tg61x8myx563ueo3urmn1ic6m.2 redis:alpine kanqcxfajd1r16wlnqcblobmm Running Running 31 minutes ago |
|
| 159 |
+``` |
|
| 160 |
+ |
|
| 161 |
+### Do not truncate output |
|
| 162 |
+ |
|
| 163 |
+When deploying a service, docker resolves the digest for the service's |
|
| 164 |
+image, and pins the service to that digest. The digest is not shown by |
|
| 165 |
+default, but is printed if `--no-trunc` is used. The `--no-trunc` option |
|
| 166 |
+also shows the non-truncated task IDs, and error-messages, as can be seen below: |
|
| 167 |
+ |
|
| 168 |
+```bash |
|
| 169 |
+$ docker stack ps --no-trunc voting |
|
| 170 |
+ID NAME IMAGE NODE DESIRED STATE CURREN STATE ERROR PORTS |
|
| 171 |
+xim5bcqtgk1bxqz91jzo4a1s5 voting_worker.1 dockersamples/examplevotingapp_worker:latest@sha256:3e4ddf59c15f432280a2c0679c4fc5a2ee5a797023c8ef0d3baf7b1385e9fed node2 Running Runnin 32 minutes ago |
|
| 172 |
+q7yik0ks1in6kv32gg6y6yjf7 voting_result.1 dockersamples/examplevotingapp_result:before@sha256:83b56996e930c292a6ae5187fda84dd6568a19d97cdb933720be15c757b7463 node1 Running Runnin 32 minutes ago |
|
| 173 |
+rx5yo0866nfxc58zf4irsss6n voting_vote.1 dockersamples/examplevotingapp_vote:before@sha256:8e64b182c87de902f2b72321c89b4af4e2b942d76d0b772532ff27ec4c6ebf6 node3 Running Runnin 32 minutes ago |
|
| 174 |
+tz6j82jnwrx7n2offljp3mn03 voting_db.1 postgres:9.4@sha256:6046af499eae34d2074c0b53f9a8b404716d415e4a03e68bc1d2f8064f2b027 node1 Running Runnin 32 minutes ago |
|
| 175 |
+w48spazhbmxcmbjfi54gs7x90 voting_redis.1 redis:alpine@sha256:9cd405cd1ec1410eaab064a1383d0d8854d1ef74a54e1e4a92fb4ec7bdc3ee7 node2 Running Runnin 32 minutes ago |
|
| 176 |
+6jj1m02freg1n3z9n1evrzsbl voting_visualizer.1 dockersamples/visualizer:stable@sha256:f924ad66c8e94b10baaf7bdb9cd491ef4e982a1d048a56a17e02bf5945401e5 node1 Running Runnin 32 minutes ago |
|
| 177 |
+kqgdmededccbhz2wuc0e9hx7g voting_vote.2 dockersamples/examplevotingapp_vote:before@sha256:8e64b182c87de902f2b72321c89b4af4e2b942d76d0b772532ff27ec4c6ebf6 node2 Running Runnin 32 minutes ago |
|
| 178 |
+t72q3z038jehe1wbh9gdum076 voting_redis.2 redis:alpine@sha256:9cd405cd1ec1410eaab064a1383d0d8854d1ef74a54e1e4a92fb4ec7bdc3ee7 node3 Running Runnin 32 minutes ago |
|
| 179 |
+``` |
|
| 180 |
+ |
|
| 181 |
+### Only display task IDs |
|
| 182 |
+ |
|
| 183 |
+The `-q ` or `--quiet` option only shows IDs of the tasks in the stack. |
|
| 184 |
+This example outputs all task IDs of the "voting" stack; |
|
| 185 |
+ |
|
| 186 |
+```bash |
|
| 187 |
+$ docker stack ps -q voting |
|
| 188 |
+xim5bcqtgk1b |
|
| 189 |
+q7yik0ks1in6 |
|
| 190 |
+rx5yo0866nfx |
|
| 191 |
+tz6j82jnwrx7 |
|
| 192 |
+w48spazhbmxc |
|
| 193 |
+6jj1m02freg1 |
|
| 194 |
+kqgdmededccb |
|
| 195 |
+t72q3z038jeh |
|
| 196 |
+``` |
|
| 197 |
+ |
|
| 198 |
+This option can be used to perform batch operations. For example, you can use |
|
| 199 |
+the task IDs as input for other commands, such as `docker inspect`. The |
|
| 200 |
+following example inspects all tasks of the "voting" stack; |
|
| 201 |
+ |
|
| 202 |
+```bash |
|
| 203 |
+$ docker inspect $(docker stack ps -q voting) |
|
| 204 |
+ |
|
| 205 |
+[ |
|
| 206 |
+ {
|
|
| 207 |
+ "ID": "xim5bcqtgk1b1gk0krq1", |
|
| 208 |
+ "Version": {
|
|
| 209 |
+(...) |
|
| 210 |
+``` |
|
| 55 | 211 |
|
| 56 | 212 |
## Related commands |
| 57 | 213 |
|