Docker Containers
Estimated reading: 4 minutes 43 views

🐳 How to See All Running Docker Containers – Complete Guide with Commands & Examples

Docker containers are at the heart of modern application deployment. Whether you’re managing microservices or debugging a failed instance, checking which containers are running is a crucial part of the workflow. In this guide, you’ll learn how to view running, stopped, and all containers using docker ps and its advanced options.


🧲 Introduction – Why Learn How to See Running Docker Containers?

As Docker becomes central to DevOps and modern infrastructure, knowing how to monitor and manage active containers is essential. Whether you’re debugging issues or validating deployments, docker ps and its variations give you full control and visibility.

🎯 In this article, you’ll learn:

  • How to list running containers
  • How to view stopped or all containers
  • Useful filters, format options, and real-world use cases
  • Examples of advanced inspection with custom outputs

βœ… How to List All Running Docker Containers

Run the following command to see only active (running) containers:

docker ps

πŸ“€ Example Output:

CONTAINER ID   IMAGE  COMMAND                  CREATED         STATUS         PORTS                  NAMES
a1b2c3d4e5f6   nginx  "/docker-entrypoint.…"   2 minutes ago   Up 2 minutes   0.0.0.0:8080->80/tcp   my-nginx

πŸ”Ž Column Descriptions:

ColumnDescription
CONTAINER IDUnique short hash for the container
IMAGEDocker image used to start the container
COMMANDThe main command or entry point
CREATEDHow long ago the container was created
STATUSCurrent state (Up/Exited/Paused)
PORTSHost-to-container port mapping
NAMESHuman-friendly container name (custom or auto-generated)

πŸ” How to View All Containers (Running + Stopped)

Use this command to view containers in any state:

docker ps -a

πŸ“€ Example Output:

CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS                      PORTS                  NAMES
a1b2c3d4e5f6   nginx     "/docker-entrypoint.…"   5 minutes ago   Exited (0) 1 minute ago                             my-nginx
c7d8e9f0g1h2   ubuntu    "/bin/bash"              10 minutes ago  Up 3 minutes                0.0.0.0:9090->80/tcp   my-ubuntu

Useful when you’re checking exited or paused containers during troubleshooting.


βš™οΈ Advanced Docker Container Listing Options

CommandDescription
docker ps -qShow only container IDs (ideal for scripts)
docker ps --filter "status=running"Filter containers by state
docker ps --format "table {{.ID}}\t{{.Names}}"Customize output (ID, Name, etc.)
docker ps -n 3Show last 3 created containers
docker ps -sShow size of each container

πŸ”§ More Examples with Output

πŸ”Ή 1. List Container IDs Only

docker ps -q

πŸ“€ Output:

a1b2c3d4e5f6
c7d8e9f0g1h2

πŸ”Ή 2. List Only Exited Containers

docker ps --filter "status=exited"

πŸ“€ Output:

CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS                    NAMES
a1b2c3d4e5f6   nginx     "/docker-entrypoint.…"   15 minutes ago  Exited (0) 2 minutes ago  my-nginx

πŸ”Ή 3. List Containers from a Specific Image

docker ps --filter "ancestor=nginx"

πŸ“€ Output:

CONTAINER ID   IMAGE     CREATED       STATUS         PORTS                  NAMES
a1b2c3d4e5f6   nginx     5 minutes ago Up 5 minutes   0.0.0.0:8080->80/tcp   my-nginx

πŸ”Ή 4. Filter Containers by Name

docker ps --filter "name=my-app"

πŸ“€ Output:

CONTAINER ID   IMAGE         CREATED        STATUS       NAMES
b2c3d4e5f6g7   node:latest   8 minutes ago  Up 8 minutes  my-app-server

πŸ”Ή 5. Format Custom Columns

docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Status}}"

πŸ“€ Output:

CONTAINER ID   NAMES          STATUS
a1b2c3d4e5f6   my-nginx       Up 2 minutes
b2c3d4e5f6g7   my-app-server  Up 8 minutes

πŸ“Œ Summary – How to See All Running Docker Containers

Knowing how to view Docker containers is fundamental to system administration, DevOps, and debugging tasks. With docker ps, -a, and filtering, you can track both running and historical container data.

πŸ” Key Takeaways:

  • Use docker ps for active containers
  • Use docker ps -a to see all containers including exited/paused
  • Add filters like --filter, --format, and -n to customize results
  • Helpful for scripting and automation (via -q)

βš™οΈ Next step: Combine with docker logs, docker stats, and docker inspect for complete container diagnostics!


❓ Frequently Asked Questions (FAQs): Summary – See All Running Docker Containers

How do I see logs from a container?

docker logs my-nginx
docker logs -f my-nginx   # Live follow mode

How do I stop all running containers?

docker stop $(docker ps -q)

πŸ“€ Output:

my-nginx
my-app-server

How do I remove all stopped containers?

docker rm $(docker ps -aq)

πŸ“€ Output:

my-nginx
ubuntu-test
old-db

How do I check container resource usage in real-time?

docker stats

πŸ“€ Output:

CONTAINER ID   NAME        CPU %   MEM USAGE / LIMIT   NET I/O     BLOCK I/O   PIDS
a1b2c3d4e5f6   my-nginx    0.03%   10.5MiB / 2GiB       1.2kB/2.5kB 0B/0B        2

How do I rename a container?

docker rename my-nginx web-server

βœ… If successful, there’s no output.


Share Now :

Leave a Reply

Your email address will not be published. Required fields are marked *

Share

How to See All Running Docker Containers

Or Copy Link

CONTENTS
Scroll to Top