containers
docker ps
Lists containers along with their status, ports, and identifiers. By default it shows only running containers unless -a is passed.
docker ps [OPTIONS] Common flags
| Flag | Purpose |
|---|---|
| -a, --all | Show all containers including stopped ones |
| -q, --quiet | Only display container IDs (useful for scripting) |
| -f, --filter | Filter output by conditions like status, name, or label |
| --format | Format output using a Go template or table syntax |
| -s, --size | Display total file size of each container |
| -n, --last | Show N last created containers regardless of state |
Examples
docker ps -a List every container including exited
docker ps -q | xargs docker stop Stop all running containers via piped IDs
docker ps --filter status=exited --filter ancestor=nginx Filter exited nginx-derived containers
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}' Custom table output
Gotcha
Without -a you only see running containers, missing exited or created ones. Filter values are exact matches unless the filter documentation explicitly supports substring matching.
Related commands
docker run
Creates and starts a new container from a specified image in a single step. This is the primary command for launching workloads and supports extensive configuration for networking, storage, and process control.
docker inspect
Returns low-level JSON metadata about Docker objects — containers, images, networks, volumes, and more. Supports Go template formatting for extracting specific fields.
docker stop
Gracefully stops one or more running containers by sending SIGTERM and then SIGKILL after a timeout. Use docker kill for an immediate SIGKILL.
docker top
Displays the running processes inside a container, similar to running ps on the host restricted to that container's PID namespace. Accepts standard ps flags after the container name.
docker exec
Runs a new command inside an already running container. Commonly used for shells, debugging, or one-off maintenance tasks.
← All Docker commands · Docker vs Kubernetes · Docker vs VMs