brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker compose ps --status filters services by state

Docker
~/tips/tip-compose-ps-status

docker compose ps --all --status=exited

Lists only the compose services in one state, such as exited or restarting.

A plain docker compose ps shows running containers. To find what stopped, crashed or never started, ask for a state.

The --status option takes one of these values: paused, restarting, removing, running, dead, created or exited. The docs say it is shorthand for --filter status=..., and the two give the same result.

docker compose ps --all --status=exited

The --all (or -a) flag shows stopped containers, including those created by the run command. I include it because a plain ps hides stopped ones, and those are the ones you are looking for. With the status filter only the exited services remain, and the output has the usual table with the exit status in the status column.

For a script, combine it with -q or --services:

docker compose ps --all --status=restarting --services

The --format json option prints one JSON object per line, matching docker ps --format json, which you can pipe to jq.

This reports the state Docker knows about. A container that is running but unhealthy still has the status running, so for that case look at the health column or use a health check with --wait.

Further reading: docker compose ps

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link