docker ps lists running containers by default; -a includes stopped ones. In CI it is used to find service containers, collect IDs for cleanup, or verify that an expected container is up before running a smoke test against it.
Common flags
-a, --all - show all containers, not just running ones
-q, --quiet - output only container IDs
--filter - filter, e.g. status=exited or name='web'
--format - Go template output for scripting
-n, --last - show the n most recently created containers
Use docker ps -aq with a name filter to gather leftover containers for forced removal between jobs. Pair --format with a health check loop to wait until a service container reports healthy before running integration tests.
Key takeaways
-a includes stopped containers; default shows only running ones.
-aq with a filter yields IDs for batch cleanup with docker rm -f.
Use --format with a status filter to wait for a container to be ready.
Frequently asked questions
docker ps Command Reference?
docker ps lists running containers by default; -a includes stopped ones. In CI it is used to find service containers, collect IDs for cleanup, or verify that an expected container is up before running a smoke test against it.
In CI?
Use docker ps -aq with a name filter to gather leftover containers for forced removal between jobs. Pair --format with a health check loop to wait until a service container reports healthy before running integration tests.