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