docker compose ps (original) (raw)

Description List containers
Usage docker compose ps [OPTIONS] [SERVICE...]

Lists containers for a Compose project, with current status and exposed ports.

By default, only running containers are shown. --all flag can be used to include stopped containers.

Option Default Description
-a, --all Show all stopped containers (including those created by the run command)
--filter Filter services by a property (supported filters: status)
--format table 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 tohttps://docs.docker.com/go/formatting/ for more information about formatting output with templates
--no-trunc Don't truncate output
--orphans true Include orphaned services (not declared by project)
-q, --quiet Only display IDs
--services Display services
--status Filter services by status. Values: [paused | restarting removing running dead created exited]

Format the output (--format)

By default, the docker compose ps command uses a table ("pretty") format to show the containers. The --format flag allows you to specify alternative presentations for the output. Currently, supported options are pretty (default), and json, which outputs information about the containers as a JSON array:

The JSON output allows you to use the information in other tools for further processing, for example, using thejq utilityto pretty-print the JSON:

Filter containers by status (--status)

Use the --status flag to filter the list of containers by status. For example, to show only containers that are running or only containers that have exited:

Filter containers by status (--filter)

The--status flag is a convenient shorthand for the --filter status=<status>flag. The example below is the equivalent to the example from the previous section, this time using the --filter flag:

The docker compose ps command currently only supports the --filter status=<status>option, but additional filter options may be added in the future.