docker_compose_ps.yaml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: quiet
  71. shorthand: q
  72. value_type: bool
  73. default_value: "false"
  74. description: Only display IDs
  75. deprecated: false
  76. hidden: false
  77. experimental: false
  78. experimentalcli: false
  79. kubernetes: false
  80. swarm: false
  81. - option: services
  82. value_type: bool
  83. default_value: "false"
  84. description: Display services
  85. deprecated: false
  86. hidden: false
  87. experimental: false
  88. experimentalcli: false
  89. kubernetes: false
  90. swarm: false
  91. - option: status
  92. value_type: stringArray
  93. default_value: '[]'
  94. description: |
  95. Filter services by status. Values: [paused | restarting | removing | running | dead | created | exited]
  96. details_url: '#status'
  97. deprecated: false
  98. hidden: false
  99. experimental: false
  100. experimentalcli: false
  101. kubernetes: false
  102. swarm: false
  103. inherited_options:
  104. - option: dry-run
  105. value_type: bool
  106. default_value: "false"
  107. description: Execute command in dry run mode
  108. deprecated: false
  109. hidden: false
  110. experimental: false
  111. experimentalcli: false
  112. kubernetes: false
  113. swarm: false
  114. examples: |-
  115. ### Format the output (--format) {#format}
  116. By default, the `docker compose ps` command uses a table ("pretty") format to
  117. show the containers. The `--format` flag allows you to specify alternative
  118. presentations for the output. Currently, supported options are `pretty` (default),
  119. and `json`, which outputs information about the containers as a JSON array:
  120. ```console
  121. $ docker compose ps --format json
  122. [{"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"}]}]
  123. ```
  124. The JSON output allows you to use the information in other tools for further
  125. processing, for example, using the [`jq` utility](https://stedolan.github.io/jq/)
  126. to pretty-print the JSON:
  127. ```console
  128. $ docker compose ps --format json | jq .
  129. [
  130. {
  131. "ID": "1553b0236cf4d2715845f053a4ee97042c4f9a2ef655731ee34f1f7940eaa41a",
  132. "Name": "example-bar-1",
  133. "Command": "/docker-entrypoint.sh nginx -g 'daemon off;'",
  134. "Project": "example",
  135. "Service": "bar",
  136. "State": "exited",
  137. "Health": "",
  138. "ExitCode": 0,
  139. "Publishers": null
  140. },
  141. {
  142. "ID": "f02a4efaabb67416e1ff127d51c4b5578634a0ad5743bd65225ff7d1909a3fa0",
  143. "Name": "example-foo-1",
  144. "Command": "/docker-entrypoint.sh nginx -g 'daemon off;'",
  145. "Project": "example",
  146. "Service": "foo",
  147. "State": "running",
  148. "Health": "",
  149. "ExitCode": 0,
  150. "Publishers": [
  151. {
  152. "URL": "0.0.0.0",
  153. "TargetPort": 80,
  154. "PublishedPort": 8080,
  155. "Protocol": "tcp"
  156. }
  157. ]
  158. }
  159. ]
  160. ```
  161. ### Filter containers by status (--status) {#status}
  162. Use the `--status` flag to filter the list of containers by status. For example,
  163. to show only containers that are running or only containers that have exited:
  164. ```console
  165. $ docker compose ps --status=running
  166. NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
  167. example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
  168. $ docker compose ps --status=exited
  169. NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
  170. example-bar-1 alpine "/entrypoint.…" bar 4 seconds ago exited (0)
  171. ```
  172. ### Filter containers by status (--filter) {#filter}
  173. The [`--status` flag](#status) is a convenient shorthand for the `--filter status=<status>`
  174. flag. The example below is the equivalent to the example from the previous section,
  175. this time using the `--filter` flag:
  176. ```console
  177. $ docker compose ps --filter status=running
  178. NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
  179. example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
  180. ```
  181. The `docker compose ps` command currently only supports the `--filter status=<status>`
  182. option, but additional filter options may be added in the future.
  183. deprecated: false
  184. hidden: false
  185. experimental: false
  186. experimentalcli: false
  187. kubernetes: false
  188. swarm: false