Skip to main content

How to List Running Docker Containers with docker ps

· 3 min read
Jagdish Kumawat
Founder @ Dewiride

Which containers are running right now, and what are they called? docker ps answers that: one line per running container, with its ID, image, status and name. This guide lists a running container, then finds it again after it stops, with real output from Docker 29.9.3.

Syntax​

Syntax
docker ps
docker ps -a
docker ps -a --filter name=NAME
PartWhat it means
docker psThe running containers
-aAll containers, stopped ones included
--filter name=NAMEOnly containers whose name matches

docker ps is short for docker container ls, whose reference describes it as "List containers", and -a as "Show all containers (default shows just running)". The same commands work in PowerShell.

Prerequisites​

  • Docker: Docker Desktop on Mac or Windows, running.
  • A running container, such as one started with docker run -d --name web nginx:alpine.

Step 1: List the Running Containers​

Terminal
docker ps
Output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
df06ddb56bd9 nginx:alpine "/docker-entrypoint.…" 22 seconds ago Up 22 seconds 80/tcp web

docker ps in a terminal: one running container, ID df06ddb56bd9, image nginx, status Up 22 seconds, port 80/tcp and name web.

  • CONTAINER ID: the start of the container's ID; commands accept it in place of the name.
  • STATUS: Up 22 seconds, running for 22 seconds.
  • PORTS: 80/tcp, the port the container listens on inside Docker; nothing is published to your computer.
  • NAMES: web, the name it was started with.

Step 2: Find a Stopped Container​

After docker stop web, the plain list is empty, and -a finds the container again:

Terminal
docker ps
docker ps -a --filter name=web
Output
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
df06ddb56bd9 nginx:alpine "/docker-entrypoint.…" 46 seconds ago Exited (0) Less than a second ago web

docker ps with only its header line, then docker ps -a --filter name=web showing the web container with the status Exited (0) Less than a second ago.

A stopped container still exists until you remove it. Exited (0) means its main process ended normally.

Common Mistakes​

MistakeWhat happensDo this instead
Looking for a stopped container with plain docker psOnly the header lineAdd -a
docker ps -a on a computer with many containersA long list of everything you ever ranAdd --filter name=...

Troubleshooting​

SymptomLikely causeFix
Your container isn't in the listIt stopped, or it was started with --rm and removed when it stoppedCheck docker ps -a; if it's not there either, it was removed

FAQ​

What's the difference between docker ps and docker container ls?​

None: the reference lists docker ps as an alias of docker container ls, along with docker container list and docker container ps.

How do I get only the IDs?​

Add -q: docker ps -q --filter name=memtest printed only 6d4241af5abf, the ID, which other commands accept.

Conclusion​

docker ps listed the running web container with its ID, status and name; after it stopped, docker ps -a --filter name=web found it as Exited (0).

Additional Resources​