List running (or all) Docker containers.
low risk
docker ps lists containers with their ID, image, command, status, and ports. The -a flag includes stopped containers. Combined with format strings, it produces machine-parseable output for automation.
| Flag | Meaning |
|---|---|
-a --all | Show all containers (not just running) |
-q --quiet | Only show container IDs |
--format | Custom output format template |
-f --filter | Filter by condition (e.g., status=exited) |
docker psShow running containers · explain & risk-check →docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'Custom table format · explain & risk-check →docker ps -q -f status=exited | xargs docker rmRemove all stopped containers · explain & risk-check →docker ps --filter name=nginxFilter containers by name · explain & risk-check →Use `docker ps --format '{{.Names}}'` to get container names for scripting — far cleaner than parsing default tabular output with awk.
Reference text is hand-written and may be incomplete — check man docker for your version. Test destructive commands on a non-production system first.