Home / Localhost / Docker ps and common commands

docker ps -a: list containers, filter, and clean output format

List running and stopped containers with docker ps -a, get a clean table with --format, filter by status, and use the commands you reach for next.

docker ps lists running containers only. Add -a to include stopped ones. The default output is wide and wraps badly in a small terminal, but --format lets you choose the columns.

Find a container and see what it is doing

  1. List running containers: docker ps.
  2. Include stopped ones with docker ps -a.
  3. Read a container's output: docker logs -f containername.
  4. Open a shell inside it: docker exec -it containername sh.

Commands you can copy

Running containers
docker ps
All containers, including stopped
docker ps -a
Only container IDs
docker ps -aq
Clean table
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
Only stopped containers
docker ps -a --filter status=exited
Show sizes
docker ps -s
Latest container
docker ps -l
Follow logs
docker logs -f containername
Shell inside a container
docker exec -it containername sh
Stop a container
docker stop containername
Compose: stop and delete data
docker compose down -v

Options explained

-a, --all
Shows all containers. The default list shows only running ones.
--format
Formats output with a template: table, table TEMPLATE, json or a Go template. Columns such as {{.Names}}, {{.Status}} and {{.Ports}} are the useful ones.
-q, --quiet
Prints only container IDs. Combine with -a to pass IDs to another command.
-f, --filter
Filters as key=value. The status filter accepts created, restarting, running, removing, paused, exited and dead. Repeat -f for several filters.
-s, --size
Shows disk size. Size is the writable layer; virtual size includes the read-only image.
-l and -n
-l shows the most recently created container in any state, -n N the last N.
A port conflict
If docker says a port is already allocated, see port is already allocated and how port mapping works.
Container exits at once
Check docker logs containername for the reason. Our Docker Compose generators list the usual startup errors for each service.
docker compose down -v
The -v also deletes the named volumes, which is where a database keeps its data. Leave it out if you want to keep the data.

Questions about Docker ps and common commands

How do I list all running Docker containers?
docker ps. Add -a to include stopped containers.
How do I get cleaner docker ps output?
Use --format with a table template, for example --format "table {{.Names}}\t{{.Status}}".
How do I see only stopped containers?
docker ps -a --filter status=exited.
How do I see what a container is logging?
docker logs -f containername.

Updated 2026-10-27

Related pages