# docker ps Command Reference

> Reference for docker ps in CI: list running or all containers with -a, -q, --filter, and --format to inspect or clean up containers in pipelines.

Source: https://latchkey.dev/learn/command-reference/docker-ps-command-reference  
Updated: 2026-06-26

List containers.

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

## Example

```shell
docker ps --filter "status=running" --format "{{.Names}} {{.Status}}"
docker rm -f $(docker ps -aq --filter "name=test-")
```

## 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.

## FAQ

### 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.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
