docker_compose_ps.yaml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. By default, both running and stopped containers are shown:
  6. ```console
  7. $ docker compose ps
  8. NAME COMMAND SERVICE STATUS PORTS
  9. example-bar-1 "/docker-entrypoint.…" bar exited (0)
  10. example-foo-1 "/docker-entrypoint.…" foo running 0.0.0.0:8080->80/tcp
  11. ```
  12. usage: docker compose ps [SERVICE...]
  13. pname: docker compose
  14. plink: docker_compose.yaml
  15. options:
  16. - option: all
  17. shorthand: a
  18. value_type: bool
  19. default_value: "false"
  20. description: |
  21. Show all stopped containers (including those created by the run command)
  22. deprecated: false
  23. hidden: false
  24. experimental: false
  25. experimentalcli: false
  26. kubernetes: false
  27. swarm: false
  28. - option: filter
  29. value_type: string
  30. description: 'Filter services by a property (supported filters: status).'
  31. details_url: '#filter'
  32. deprecated: false
  33. hidden: false
  34. experimental: false
  35. experimentalcli: false
  36. kubernetes: false
  37. swarm: false
  38. - option: format
  39. value_type: string
  40. default_value: pretty
  41. description: 'Format the output. Values: [pretty | json]'
  42. details_url: '#format'
  43. deprecated: false
  44. hidden: false
  45. experimental: false
  46. experimentalcli: false
  47. kubernetes: false
  48. swarm: false
  49. - option: quiet
  50. shorthand: q
  51. value_type: bool
  52. default_value: "false"
  53. description: Only display IDs
  54. deprecated: false
  55. hidden: false
  56. experimental: false
  57. experimentalcli: false
  58. kubernetes: false
  59. swarm: false
  60. - option: services
  61. value_type: bool
  62. default_value: "false"
  63. description: Display services
  64. deprecated: false
  65. hidden: false
  66. experimental: false
  67. experimentalcli: false
  68. kubernetes: false
  69. swarm: false
  70. - option: status
  71. value_type: stringArray
  72. default_value: '[]'
  73. description: |
  74. Filter services by status. Values: [paused | restarting | removing | running | dead | created | exited]
  75. details_url: '#status'
  76. deprecated: false
  77. hidden: false
  78. experimental: false
  79. experimentalcli: false
  80. kubernetes: false
  81. swarm: false
  82. examples: |-
  83. ### Format the output (--format) {#format}
  84. By default, the `docker compose ps` command uses a table ("pretty") format to
  85. show the containers. The `--format` flag allows you to specify alternative
  86. presentations for the output. Currently supported options are `pretty` (default),
  87. and `json`, which outputs information about the containers as a JSON array:
  88. ```console
  89. $ docker compose ps --format json
  90. [{"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"}]}]
  91. ```
  92. The JSON output allows you to use the information in other tools for further
  93. processing, for example, using the [`jq` utility](https://stedolan.github.io/jq/){:target="_blank" rel="noopener" class="_"}
  94. to pretty-print the JSON:
  95. ```console
  96. $ docker compose ps --format json | jq .
  97. [
  98. {
  99. "ID": "1553b0236cf4d2715845f053a4ee97042c4f9a2ef655731ee34f1f7940eaa41a",
  100. "Name": "example-bar-1",
  101. "Command": "/docker-entrypoint.sh nginx -g 'daemon off;'",
  102. "Project": "example",
  103. "Service": "bar",
  104. "State": "exited",
  105. "Health": "",
  106. "ExitCode": 0,
  107. "Publishers": null
  108. },
  109. {
  110. "ID": "f02a4efaabb67416e1ff127d51c4b5578634a0ad5743bd65225ff7d1909a3fa0",
  111. "Name": "example-foo-1",
  112. "Command": "/docker-entrypoint.sh nginx -g 'daemon off;'",
  113. "Project": "example",
  114. "Service": "foo",
  115. "State": "running",
  116. "Health": "",
  117. "ExitCode": 0,
  118. "Publishers": [
  119. {
  120. "URL": "0.0.0.0",
  121. "TargetPort": 80,
  122. "PublishedPort": 8080,
  123. "Protocol": "tcp"
  124. }
  125. ]
  126. }
  127. ]
  128. ```
  129. ### Filter containers by status (--status) {#status}
  130. Use the `--status` flag to filter the list of containers by status. For example,
  131. to show only containers that are running, or only containers that have exited:
  132. ```console
  133. $ docker compose ps --status=running
  134. NAME COMMAND SERVICE STATUS PORTS
  135. example-foo-1 "/docker-entrypoint.…" foo running 0.0.0.0:8080->80/tcp
  136. $ docker compose ps --status=exited
  137. NAME COMMAND SERVICE STATUS PORTS
  138. example-bar-1 "/docker-entrypoint.…" bar exited (0)
  139. ```
  140. ### Filter containers by status (--filter) {#filter}
  141. The [`--status` flag](#status) is a convenience shorthand for the `--filter status=<status>`
  142. flag. The example below is the equivalent to the example from the previous section,
  143. this time using the `--filter` flag:
  144. ```console
  145. $ docker compose ps --filter status=running
  146. NAME COMMAND SERVICE STATUS PORTS
  147. example-foo-1 "/docker-entrypoint.…" foo running 0.0.0.0:8080->80/tcp
  148. $ docker compose ps --filter status=running
  149. NAME COMMAND SERVICE STATUS PORTS
  150. example-bar-1 "/docker-entrypoint.…" bar exited (0)
  151. ```
  152. The `docker compose ps` command currently only supports the `--filter status=<status>`
  153. option, but additional filter options may be added in future.
  154. deprecated: false
  155. experimental: false
  156. experimentalcli: false
  157. kubernetes: false
  158. swarm: false