2021-03-08 15:47:24 +01:00
|
|
|
command: docker compose ps
|
|
|
|
short: List containers
|
2021-09-13 17:41:21 +02:00
|
|
|
long: |-
|
2022-07-26 14:58:08 +02:00
|
|
|
Lists containers for a Compose project, with current status and exposed ports.
|
2021-09-13 17:41:21 +02:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
```console
|
|
|
|
$ docker compose ps
|
2023-01-24 09:10:09 +01:00
|
|
|
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
|
|
|
example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
|
|
|
|
```
|
|
|
|
|
2023-10-31 11:50:42 +01:00
|
|
|
By default, only running containers are shown. `--all` flag can be used to include stopped containers.
|
2023-01-24 09:10:09 +01:00
|
|
|
|
|
|
|
```console
|
|
|
|
$ docker compose ps --all
|
|
|
|
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
|
|
|
example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
|
|
|
|
example-bar-1 alpine "/entrypoint.…" bar 4 seconds ago exited (0)
|
2022-07-26 14:58:08 +02:00
|
|
|
```
|
2022-08-02 13:11:57 +02:00
|
|
|
usage: docker compose ps [OPTIONS] [SERVICE...]
|
2021-03-08 15:47:24 +01:00
|
|
|
pname: docker compose
|
|
|
|
plink: docker_compose.yaml
|
|
|
|
options:
|
2022-07-26 14:58:08 +02:00
|
|
|
- option: all
|
|
|
|
shorthand: a
|
|
|
|
value_type: bool
|
|
|
|
default_value: "false"
|
|
|
|
description: |
|
|
|
|
Show all stopped containers (including those created by the run command)
|
|
|
|
deprecated: false
|
|
|
|
hidden: false
|
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
|
|
|
- option: filter
|
|
|
|
value_type: string
|
|
|
|
description: 'Filter services by a property (supported filters: status).'
|
|
|
|
details_url: '#filter'
|
|
|
|
deprecated: false
|
|
|
|
hidden: false
|
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
|
|
|
- option: format
|
|
|
|
value_type: string
|
2022-12-11 10:59:01 +01:00
|
|
|
default_value: table
|
2023-08-22 09:26:09 +02:00
|
|
|
description: |-
|
|
|
|
Format output using a custom template:
|
|
|
|
'table': Print output in table format with column headers (default)
|
|
|
|
'table TEMPLATE': Print output in table format using the given Go template
|
|
|
|
'json': Print in JSON format
|
|
|
|
'TEMPLATE': Print output using the given Go template.
|
|
|
|
Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates
|
2022-07-26 14:58:08 +02:00
|
|
|
details_url: '#format'
|
|
|
|
deprecated: false
|
|
|
|
hidden: false
|
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
2023-09-22 16:09:14 +02:00
|
|
|
- option: no-trunc
|
|
|
|
value_type: bool
|
|
|
|
default_value: "false"
|
|
|
|
description: Don't truncate output
|
|
|
|
deprecated: false
|
|
|
|
hidden: false
|
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
2023-11-23 11:53:19 +01:00
|
|
|
- option: orphans
|
|
|
|
value_type: bool
|
|
|
|
default_value: "true"
|
|
|
|
description: Include orphaned services (not declared by project)
|
|
|
|
deprecated: false
|
|
|
|
hidden: false
|
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
2022-07-26 14:58:08 +02:00
|
|
|
- option: quiet
|
|
|
|
shorthand: q
|
|
|
|
value_type: bool
|
|
|
|
default_value: "false"
|
|
|
|
description: Only display IDs
|
|
|
|
deprecated: false
|
|
|
|
hidden: false
|
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
|
|
|
- option: services
|
|
|
|
value_type: bool
|
|
|
|
default_value: "false"
|
|
|
|
description: Display services
|
|
|
|
deprecated: false
|
|
|
|
hidden: false
|
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
|
|
|
- option: status
|
|
|
|
value_type: stringArray
|
|
|
|
default_value: '[]'
|
|
|
|
description: |
|
|
|
|
Filter services by status. Values: [paused | restarting | removing | running | dead | created | exited]
|
|
|
|
details_url: '#status'
|
|
|
|
deprecated: false
|
|
|
|
hidden: false
|
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
2023-05-05 12:43:27 +02:00
|
|
|
inherited_options:
|
|
|
|
- option: dry-run
|
|
|
|
value_type: bool
|
|
|
|
default_value: "false"
|
|
|
|
description: Execute command in dry run mode
|
|
|
|
deprecated: false
|
|
|
|
hidden: false
|
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
2022-03-10 16:53:38 +01:00
|
|
|
examples: |-
|
2022-07-26 14:58:08 +02:00
|
|
|
### Format the output (--format) {#format}
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
By default, the `docker compose ps` command uses a table ("pretty") format to
|
|
|
|
show the containers. The `--format` flag allows you to specify alternative
|
2022-11-29 16:52:22 +01:00
|
|
|
presentations for the output. Currently, supported options are `pretty` (default),
|
2022-07-26 14:58:08 +02:00
|
|
|
and `json`, which outputs information about the containers as a JSON array:
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
```console
|
|
|
|
$ docker compose ps --format json
|
|
|
|
[{"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"}]}]
|
|
|
|
```
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
The JSON output allows you to use the information in other tools for further
|
2023-10-31 11:50:42 +01:00
|
|
|
processing, for example, using the [`jq` utility](https://stedolan.github.io/jq/)
|
2022-07-26 14:58:08 +02:00
|
|
|
to pretty-print the JSON:
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
```console
|
|
|
|
$ docker compose ps --format json | jq .
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"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"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
```
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
### Filter containers by status (--status) {#status}
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
Use the `--status` flag to filter the list of containers by status. For example,
|
2022-11-29 16:52:22 +01:00
|
|
|
to show only containers that are running or only containers that have exited:
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
```console
|
|
|
|
$ docker compose ps --status=running
|
2023-01-24 09:10:09 +01:00
|
|
|
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
|
|
|
example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
$ docker compose ps --status=exited
|
2023-01-24 09:10:09 +01:00
|
|
|
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
|
|
|
example-bar-1 alpine "/entrypoint.…" bar 4 seconds ago exited (0)
|
2022-07-26 14:58:08 +02:00
|
|
|
```
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
### Filter containers by status (--filter) {#filter}
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-11-29 16:52:22 +01:00
|
|
|
The [`--status` flag](#status) is a convenient shorthand for the `--filter status=<status>`
|
2022-07-26 14:58:08 +02:00
|
|
|
flag. The example below is the equivalent to the example from the previous section,
|
|
|
|
this time using the `--filter` flag:
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
```console
|
|
|
|
$ docker compose ps --filter status=running
|
2023-01-24 09:10:09 +01:00
|
|
|
NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS
|
|
|
|
example-foo-1 alpine "/entrypoint.…" foo 4 seconds ago Up 2 seconds 0.0.0.0:8080->80/tcp
|
2022-07-26 14:58:08 +02:00
|
|
|
```
|
2022-03-10 16:53:38 +01:00
|
|
|
|
2022-07-26 14:58:08 +02:00
|
|
|
The `docker compose ps` command currently only supports the `--filter status=<status>`
|
2022-11-29 16:52:22 +01:00
|
|
|
option, but additional filter options may be added in the future.
|
2021-03-08 15:47:24 +01:00
|
|
|
deprecated: false
|
2023-07-07 14:27:14 +02:00
|
|
|
hidden: false
|
2021-03-08 15:47:24 +01:00
|
|
|
experimental: false
|
|
|
|
experimentalcli: false
|
|
|
|
kubernetes: false
|
|
|
|
swarm: false
|
|
|
|
|