docker_compose_ps.yaml 7.1 KB

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