Multiple ways to List containers in a Docker with examples

This tutorial explains multiple ways to show a list of containers in the Docker

Docker Container List command example

The docker ps command is used for the list of containers with different options. It is an alias for the docker container ls command

The following are different commands

docker container ls
docker ps

docker ps command has the following options

  • -a or --all: Displays all containers(default lists running containers)
  • -f or --filter: filter based on conditions. Example display exited containers with status=‘exited’
  • -n or --last int: last n number containers
  • -s or --size: show total file sizes

To show a list of containers in a docker, please follow the below steps.

Containers can be in a state of running or stopped.

  • Display all running containers
docker ps


1fdb4b122a13 localstack "top" 3 weeks ago Up 3 days localstack
  • Show running and stopping containers, Run with the -a(all states) option
docker ps -a
  • To display the latest created containers
docker ps -l
  • display all stopped containers
docker ps -f "status=excited"
docker ps --filter "status=excited"
  • List all container ids only
docker ps -q
  • Display all 3 last created containers
docker ps -a -n3
  • to show all file sizes This container displays the SIZE column( with virtual memory)
docker ps -s

What does docker ps mean?

ps is a name used for process status in Unix OS, Docker ps is used to find the container status and it has different options for listing containers with running status, sizes, last created containers