On this pageRead the default table
docker ps answers the most common question on a container host: what is running right now? Its default view also hides the containers you need most when something breaks, because a container that crashed is no longer running. A few flags, filters and templates turn it into a precise inventory tool, and into a safe starting point for cleanup scripts.
Read the default table
docker ps and docker container ls are the same command. The second name exists because the CLI groups commands by object type. With no options, it prints one row per running container:
| Column | What it tells you |
|---|---|
CONTAINER ID |
The first 12 characters of the ID; any unique prefix works in other commands |
IMAGE |
The image the container was created from, as typed at creation |
COMMAND |
The entrypoint and command, truncated |
CREATED |
When the container was created, not when it last started |
STATUS |
Up or exited, for how long, plus the health check result if one exists |
PORTS |
Published ports, such as 0.0.0.0:443->443/tcp |
NAMES |
The name you gave it, or a generated one |
STATUS carries the most information. Up 3 hours (healthy) means the health check passes. Exited (0) is a clean stop and Exited (1) usually means the application failed on its own. Exited (137) is 128 plus signal 9: something killed the process, often the kernel's out-of-memory killer, which docker inspect -f '{{.State.OOMKilled}}' web confirms. Exited (143) is 128 plus 15, the normal SIGTERM sent by docker stop.
A PORTS entry that starts with 0.0.0.0 or [::] listens on every interface of the host. On a public server that deserves a second look, because Docker writes its own firewall rules and published ports can bypass a host firewall such as UFW. The Docker security checklist covers how to close that gap.
Show more, or less
| Flag | Effect |
|---|---|
-a, --all |
Include stopped, created and dead containers |
-q, --quiet |
Print IDs only, one per line, for scripts |
-n 5, --last 5 |
The five most recently created containers, in any state |
-l, --latest |
Only the most recently created container |
-s, --size |
Add disk usage per container |
--no-trunc |
Full IDs and full commands |
The combinations you will type most:
docker ps -a # everything, including crashed containers
docker ps -l # what did I just start?
docker ps -a --no-trunc # read each container's full command
docker ps -s # which container is filling the disk?
With -s, the size column shows two numbers. The first is the container's writable layer: files the container created or changed since it started. The second, labeled virtual, adds the read-only image layers, which are shared with every container built from the same image, so adding up virtual sizes overstates real disk use. A writable layer that keeps growing usually means an application is writing logs or uploads inside the container instead of to a volume.
Filter instead of piping to grep
--filter (short form -f) makes the daemon do the matching. The output stays clean for scripts, and you never match a word in the wrong column.
| Filter | Example | Matches |
|---|---|---|
status |
status=exited |
created, restarting, running, removing, paused, exited or dead |
exited |
exited=137 |
An exit code (combine with -a) |
health |
health=unhealthy |
starting, healthy, unhealthy or none |
name |
name=web |
All or part of a name |
label |
label=env=prod |
A label key, or a key and value |
ancestor |
ancestor=nginx |
Containers built from an image, by name, ID or digest |
publish |
publish=443 |
A published port or port range |
network |
network=backend |
Containers attached to a network |
volume |
volume=pgdata |
Containers using a volume or mount path |
since, before |
since=web |
Created after or before another container |
Repeat --filter to combine conditions. Two values for the same key match either one, while different keys must all match:
# crashed rather than stopped on purpose
docker ps -a --filter status=exited --filter exited=1 --filter exited=137
# everything failing its health check right now
docker ps --filter health=unhealthy
# which container owns port 443?
docker ps --filter publish=443
# what still uses an image before you delete it
docker ps -a --filter ancestor=postgres:16
The name filter matches any part of a name, so name=web also lists web-old and webhook. Check the NAMES column before you act on the result.
Format the output
--format takes a Go template. Start it with table to keep headers and aligned columns, or leave that word out to get plain lines that scripts can split.
docker ps --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}'
docker ps -a --format '{{.Names}} {{.State}} {{.Image}}'
docker ps --format '{{.Names}}: {{.Label "com.docker.compose.project"}}'
The placeholders you will reach for are .ID, .Names, .Image, .Command, .CreatedAt, .RunningFor, .Status, .State, .Ports, .Size, .Labels, .Mounts and .Networks. .State returns the bare state, such as running or exited, which is far easier to test in a script than the human-readable .Status. .Label followed by a quoted key pulls out a single label.
For anything more involved, ask for JSON. The CLI prints one object per container, one per line, which jq reads directly:
docker ps -a --format json | jq -r 'select(.State != "running") | .Names'
docker ps --format json | jq -r '[.Names, .Image, .RunningFor] | @tsv'
If you always want the same columns, set a default in ~/.docker/config.json. It applies whenever you do not pass --format. Add the key next to whatever the file already contains, such as registry logins:
{
"psFormat": "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}"
}
Compose projects have their own view
Inside a project directory, docker compose ps lists only that project's containers and shows each one's service name:
docker compose ps # running services of this project
docker compose ps -a # include exited ones
docker compose ps --status exited # only the ones that stopped
docker compose ps --services # service names, one per line
docker compose ps --format json # JSON lines for scripts
Compose labels every container it creates, so the plain CLI can find any project from anywhere on the host, and docker compose ls lists the projects themselves:
docker ps -a --filter label=com.docker.compose.project=shop
docker ps --format 'table {{.Label "com.docker.compose.project"}}\t{{.Names}}\t{{.Status}}'
Related questions, one command each
docker ps shows state. These companions answer the next question without opening a shell inside the container:
| Question | Command |
|---|---|
| How much CPU and memory is each container using? | docker stats --no-stream |
| How many times has it restarted? | docker inspect -f '{{.RestartCount}}' web |
| What is its IP address on each network? | docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}} {{end}}' web |
| Which processes run inside it? | docker top web |
A restart count that keeps climbing while STATUS shows Up 20 seconds is a crash loop. Read the last lines before each exit with docker logs --tail 50 web.
Clean up from a filtered list
Because -q prints bare IDs, any filtered list can feed another command. Run the listing on its own first, read it, then add the action.
# remove stopped containers created more than a day ago (asks to confirm)
docker container prune --filter until=24h
# remove exited CI containers only
docker ps -aq --filter status=exited --filter label=env=ci | xargs -r docker rm
# stop everything still running an old image tag
docker ps -q --filter ancestor=myapp:1.2 | xargs -r docker stop
xargs -r skips the command when the list is empty, which avoids the error that docker rm $(...) prints when nothing matches. Removing a container deletes its writable layer for good. Named volumes survive docker rm, and so do anonymous ones unless you add -v, so data kept in volumes is safe while files written inside the container itself are not.
Every command here works the same on a laptop and on a server. A CloudSat server deployed with the Docker one-click app starts with Docker Engine, Compose and Buildx installed, so the first SSH session is enough to try them.
FAQ
Why does docker ps show nothing when I know containers exist?
Either they have stopped, so add -a, or your CLI is talking to a different daemon. Containers started with sudo docker belong to the system daemon, while rootless Docker runs a separate daemon per user, and each one lists only its own containers. docker context ls shows which endpoint is active.
Is docker container ls any different from docker ps?
No. docker ps, docker container ls, docker container list and docker container ps are aliases of one command with the same flags. Scripts often use the longer form because it reads consistently next to docker image ls and docker volume ls.
How do I list containers on another server?
Point the CLI at the remote engine over SSH, for example docker -H ssh://deploy@203.0.113.10 ps, or save the connection as a context. The guide to remote Docker over SSH sets this up properly, including connection reuse.
How do I print only container names?
docker ps --format '{{.Names}}' prints one name per line. Add -a to include stopped containers, or a --filter to narrow the list first.
Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.




