docker_compose_ps.yaml 6.7 KB

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