docker_compose_ps.yaml 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. command: docker compose ps
  2. short: List containers
  3. long: |-
  4. Lists containers for a Compose project, with current status and exposed ports.
  5. ```console
  6. $ docker compose ps
  7. NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
  8. example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
  9. ```
  10. By default, only running containers are shown. `--all` flag can be used to include stopped containers.
  11. ```console
  12. $ docker compose ps --all
  13. NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
  14. example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
  15. example-bar-1 alpine "/entrypoint.…" bar 4 seconds ago exited (0)
  16. ```
  17. usage: docker compose ps [OPTIONS] [SERVICE...]
  18. pname: docker compose
  19. plink: docker_compose.yaml
  20. options:
  21. - option: all
  22. shorthand: a
  23. value_type: bool
  24. default_value: "false"
  25. description: |
  26. Show all stopped containers (including those created by the run command)
  27. deprecated: false
  28. hidden: false
  29. experimental: false
  30. experimentalcli: false
  31. kubernetes: false
  32. swarm: false
  33. - option: filter
  34. value_type: string
  35. description: 'Filter services by a property (supported filters: status)'
  36. details_url: '#filter'
  37. deprecated: false
  38. hidden: false
  39. experimental: false
  40. experimentalcli: false
  41. kubernetes: false
  42. swarm: false
  43. - option: format
  44. value_type: string
  45. default_value: table
  46. description: |-
  47. Format output using a custom template:
  48. 'table': Print output in table format with column headers (default)
  49. 'table TEMPLATE': Print output in table format using the given Go template
  50. 'json': Print in JSON format
  51. 'TEMPLATE': Print output using the given Go template.
  52. Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates
  53. details_url: '#format'
  54. deprecated: false
  55. hidden: false
  56. experimental: false
  57. experimentalcli: false
  58. kubernetes: false
  59. swarm: false
  60. - option: no-trunc
  61. value_type: bool
  62. default_value: "false"
  63. description: Don't truncate output
  64. deprecated: false
  65. hidden: false
  66. experimental: false
  67. experimentalcli: false
  68. kubernetes: false
  69. swarm: false
  70. - option: orphans
  71. value_type: bool
  72. default_value: "true"
  73. description: Include orphaned services (not declared by project)
  74. deprecated: false
  75. hidden: false
  76. experimental: false
  77. experimentalcli: false
  78. kubernetes: false
  79. swarm: false
  80. - option: quiet
  81. shorthand: q
  82. value_type: bool
  83. default_value: "false"
  84. description: Only display IDs
  85. deprecated: false
  86. hidden: false
  87. experimental: false
  88. experimentalcli: false
  89. kubernetes: false
  90. swarm: false
  91. - option: services
  92. value_type: bool
  93. default_value: "false"
  94. description: Display services
  95. deprecated: false
  96. hidden: false
  97. experimental: false
  98. experimentalcli: false
  99. kubernetes: false
  100. swarm: false
  101. - option: status
  102. value_type: stringArray
  103. default_value: '[]'
  104. description: |
  105. Filter services by status. Values: [paused | restarting | removing | running | dead | created | exited]
  106. details_url: '#status'
  107. deprecated: false
  108. hidden: false
  109. experimental: false
  110. experimentalcli: false
  111. kubernetes: false
  112. swarm: false
  113. inherited_options:
  114. - option: dry-run
  115. value_type: bool
  116. default_value: "false"
  117. description: Execute command in dry run mode
  118. deprecated: false
  119. hidden: false
  120. experimental: false
  121. experimentalcli: false
  122. kubernetes: false
  123. swarm: false
  124. examples: |-
  125. ### Format the output (--format) {#format}
  126. By default, the `docker compose ps` command uses a table ("pretty") format to
  127. show the containers. The `--format` flag allows you to specify alternative
  128. presentations for the output. Currently, supported options are `pretty` (default),
  129. and `json`, which outputs information about the containers as a JSON array:
  130. ```console
  131. $ docker compose ps --format json
  132. [{"ID":"1553b0236cf4d2715845f053a4ee97042c4f9a2ef655731ee34f1f7940eaa41a","Name":"example-bar-1","Command":"/docker-entrypoint.sh nginx -g 'daemon off;'","Project":"example","Service":"bar","State":"exited","Health":"","ExitCode":0,"Publishers":null},{"ID":"f02a4efaabb67416e1ff127d51c4b5578634a0ad5743bd65225ff7d1909a3fa0","Name":"example-foo-1","Command":"/docker-entrypoint.sh nginx -g 'daemon off;'","Project":"example","Service":"foo","State":"running","Health":"","ExitCode":0,"Publishers":[{"URL":"0.0.0.0","TargetPort":80,"PublishedPort":8080,"Protocol":"tcp"}]}]
  133. ```
  134. The JSON output allows you to use the information in other tools for further
  135. processing, for example, using the [`jq` utility](https://stedolan.github.io/jq/)
  136. to pretty-print the JSON:
  137. ```console
  138. $ docker compose ps --format json | jq .
  139. [
  140. {
  141. "ID": "1553b0236cf4d2715845f053a4ee97042c4f9a2ef655731ee34f1f7940eaa41a",
  142. "Name": "example-bar-1",
  143. "Command": "/docker-entrypoint.sh nginx -g 'daemon off;'",
  144. "Project": "example",
  145. "Service": "bar",
  146. "State": "exited",
  147. "Health": "",
  148. "ExitCode": 0,
  149. "Publishers": null
  150. },
  151. {
  152. "ID": "f02a4efaabb67416e1ff127d51c4b5578634a0ad5743bd65225ff7d1909a3fa0",
  153. "Name": "example-foo-1",
  154. "Command": "/docker-entrypoint.sh nginx -g 'daemon off;'",
  155. "Project": "example",
  156. "Service": "foo",
  157. "State": "running",
  158. "Health": "",
  159. "ExitCode": 0,
  160. "Publishers": [
  161. {
  162. "URL": "0.0.0.0",
  163. "TargetPort": 80,
  164. "PublishedPort": 8080,
  165. "Protocol": "tcp"
  166. }
  167. ]
  168. }
  169. ]
  170. ```
  171. ### Filter containers by status (--status) {#status}
  172. Use the `--status` flag to filter the list of containers by status. For example,
  173. to show only containers that are running or only containers that have exited:
  174. ```console
  175. $ docker compose ps --status=running
  176. NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
  177. example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
  178. $ docker compose ps --status=exited
  179. NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
  180. example-bar-1 alpine "/entrypoint.…" bar 4 seconds ago exited (0)
  181. ```
  182. ### Filter containers by status (--filter) {#filter}
  183. The [`--status` flag](#status) is a convenient shorthand for the `--filter status=<status>`
  184. flag. The example below is the equivalent to the example from the previous section,
  185. this time using the `--filter` flag:
  186. ```console
  187. $ docker compose ps --filter status=running
  188. NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
  189. example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
  190. ```
  191. The `docker compose ps` command currently only supports the `--filter status=<status>`
  192. option, but additional filter options may be added in the future.
  193. deprecated: false
  194. hidden: false
  195. experimental: false
  196. experimentalcli: false
  197. kubernetes: false
  198. swarm: false