Docker Containers
Estimated reading: 3 minutes 8 views

🐳 How to See All Running Docker Containers

Docker containers are an efficient and scalable way to run applications. As you work with Docker, you’ll often need to check which containers are running, stopped, or paused. This guide walks you through all the key commands to list Docker containers, with real example outputs for each scenario.


✅ How to List All Running Containers

Use the following command to view all currently 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

Columns Explained:

  • CONTAINER ID – Unique container identifier
  • IMAGE – Docker image used
  • COMMAND – Entry point or shell command
  • CREATED – How long ago it was started
  • STATUS – Indicates if it’s running or not
  • PORTS – Port mappings
  • NAMES – Container name (custom or auto-generated)

🔍 View All Containers (Including Stopped)

To see both running and stopped containers, use:

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

Use this when debugging stopped containers or checking historical container activity.


⚙️ Advanced Listing Options

Here are additional ways to customize your container listings:

CommandDescription
docker ps -qShow only container IDs (useful for scripting)
docker ps --filter "status=running"Show only containers in a specific state
docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Status}}"Customize output format
docker ps -n 3Show the last 3 created containers
docker ps -sShow container size (disk usage)

🔧 Examples with Outputs

1. List only container IDs

docker ps -q

📤 Example Output:

a1b2c3d4e5f6
c7d8e9f0g1h2

2. List only exited containers

docker ps --filter "status=exited"

📤 Example Output:

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

3. Find containers using a specific image (e.g., nginx)

docker ps --filter "ancestor=nginx"

📤 Example Output:

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

4. Show containers with a name prefix (e.g., my-app)

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

📤 Example Output:

CONTAINER ID   IMAGE         COMMAND     CREATED        STATUS       PORTS     NAMES
b2c3d4e5f6g7 node:latest "npm start" 8 minutes ago Up 8 minutes my-app-server

5. Format Output with Custom Columns

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

📤 Example Output:

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

✅ Final Thought

Monitoring and managing your containers starts with mastering the docker ps command. Whether you’re checking active workloads or debugging failed ones, these tools give you total visibility and control.

🔗 For more advanced management, check the official Docker ps docs.


❓ Frequently Asked Questions (FAQs)


📌 Q1: How do I see the logs of a running container?

docker logs my-nginx

📤 Sample Output:

172.17.0.1 - - [11/Apr/2025:12:00:00 +0000] "GET / HTTP/1.1" 200 612 "-" "Mozilla/5.0"

➡️ For real-time logs, use:

docker logs -f my-nginx

📌 Q2: How do I stop all running containers?

docker stop $(docker ps -q)

📤 Example Output:

my-nginx
my-app-server

📌 Q3: How do I remove all stopped containers?

docker rm $(docker ps -aq)

📤 Example Output:

my-nginx
ubuntu-test
old-db

📌 Q4: How do I check real-time container resource usage (CPU, Memory)?

docker stats

📤 Sample 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

📌 Q5: How do I rename a container?

docker rename my-nginx web-server

📤 Output:

no output if successful)


Leave a Reply

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

Share this Doc

How to See All Running Docker Containers

Or copy link

CONTENTS
Scroll to Top