Docker List Containers: A Complete Guide to Container Management
- Eliodra Rechel
- Aug 26
- 6 min read
Managing Docker containers efficiently is essential for developers and DevOps professionals. Whether you're working with a handful of containers or orchestrating dozens across multiple environments, knowing how to list, filter, and format container information is a fundamental skill. This comprehensive guide will walk you through everything you need to know about listing Docker containers, from basic commands to advanced techniques.

Why Listing Docker Containers Matters
Before diving into commands, let's understand why being able to list containers effectively is crucial for Docker workflows:
Monitoring container health and status
Troubleshooting application issues
Managing system resources efficiently
Identifying unused or orphaned containers
Ensuring security by tracking all running containers
Docker containers are isolated environments that package applications and their dependencies. As your infrastructure grows, keeping track of these containers becomes increasingly important.
Effective container listing helps you maintain visibility into your Docker environment, making it easier to manage resources, troubleshoot issues, and ensure that your applications are running as expected.
The docker ps command and its variations are your primary tools for gaining this visibility. Let's explore how to use them effectively.
Basic Usage of docker ps Command
The most fundamental command for listing Docker containers is docker ps. By default, this command shows only running containers.
Understanding the Output Columns
When you run docker ps, the output includes several columns of information:
Column | Description |
CONTAINER ID | Unique identifier for the container |
IMAGE | The Docker image used to create the container |
COMMAND | The command that was used to start the container |
CREATED | When the container was created |
STATUS | Current state (running, exited, etc.) |
PORTS | Exposed ports and their mappings |
NAMES | Assigned name of the container |
Example: Listing Running Containers
To list all running containers, simply use:
docker ps
This will display all currently active containers on your system.
Listing All Docker Containers (Including Stopped Ones)
To see all containers on your system, including those that are not currently running, use the -a or --all flag:
docker ps -a
This command reveals all containers in any state, including:
Running - Active containers
Exited - Containers that have stopped
Created - Containers that were created but never started
Paused - Containers that have been temporarily paused
Restarting - Containers in the process of restarting
Tip: Stopped containers still consume disk space. If you're looking to free up resources, you might want to remove unused containers with docker rm after identifying them with docker ps -a.
Filtering Docker Container Lists
Docker provides powerful filtering capabilities to help you find specific containers. The --filter (or -f) flag allows you to narrow down results based on various criteria.
Filtering by Container Status
One of the most common filtering needs is to list containers by their status:
docker ps -a --filter "status=exited"
This command shows only containers that have exited (stopped).
Other Useful Filter Options
Filtering by Name
To find containers with names containing a specific string:
docker ps --filter "name=web"
Filtering by Label
To find containers with specific labels:
docker ps --filter "label=environment=production"
Filtering by Network
To list containers connected to a specific network:
docker ps --filter "network=bridge"
Combining Multiple Filters
You can use multiple filters together:
docker ps --filter "status=running" --filter "label=app=web"
Filters are incredibly powerful when managing large Docker environments. They allow you to quickly identify specific subsets of containers for monitoring, maintenance, or troubleshooting.
— Docker best practices
Customizing Docker Container List Output
The default output of docker ps is comprehensive but sometimes you need a more tailored view. Docker allows you to customize the output format using Go templates.
Using the --format Flag
The --format flag lets you specify exactly which information you want to display and how:
Common Format Examples
Use Case | Command | Output |
Show only IDs and names | docker ps --format "{{.ID}}: {{.Names}}" | ab3f4d5e6c7b: web-server |
Create a custom table | docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" | Tabular output with names, status, and ports |
Show container details | docker ps --format "{{.Names}} is using {{.Image}} ({{.Status}})" | web-server is using nginx:latest (Up 3 hours) |
Available Format Placeholders
You can use the following placeholders in your format string:
{{.ID}} - Container ID
{{.Image}} - Image name
{{.Command}} - Command
{{.CreatedAt}} - Time when the container was created
{{.RunningFor}} - Time since the container was started
{{.Ports}} - Exposed ports
{{.Status}} - Container status
{{.Size}} - Container disk size
{{.Names}} - Container name
{{.Networks}} - Networks the container is connected to
Practical Docker Container Listing Examples
Let's explore some real-world scenarios and how to use docker ps commands to address them:
Finding Resource-Intensive Containers
To list containers with their size information:
docker ps --size
This adds a SIZE column showing the disk space used by each container.
Listing Only Container IDs
To get just the container IDs (useful for scripting):
docker ps -q
This is particularly useful when you need to perform operations on multiple containers.
Viewing Latest Created Container
To see only the most recently created container:
docker ps -l
Or to see the N most recently created containers:
docker ps -n 5
Advanced Usage Examples
Removing All Stopped Containers
First list, then remove all stopped containers:
docker ps -a -f status=exited -q | xargs docker rm
This command chains the listing of exited containers with the remove command.
Displaying Full Container IDs
By default, Docker truncates container IDs. To see full IDs:
docker ps --no-trunc
This is useful when you need the complete container ID for specific operations.
Common Errors and Troubleshooting
When working with Docker container listing commands, you might encounter some common issues. Here's how to address them:
Why can't I see any containers with docker ps?
If docker ps shows no containers, it means no containers are currently running. Try docker ps -a to see all containers, including stopped ones. If you still see nothing, ensure Docker is running with docker info.
Why are my container names truncated?
By default, Docker truncates output for readability. Use docker ps --no-trunc to see full container IDs, names, and commands.
How do I fix "Error response from daemon" when listing containers?
This usually indicates an issue with the Docker daemon. Try restarting the Docker service with sudo service docker restart or the equivalent command for your operating system.
Why does filtering not work as expected?
Ensure you're using the correct syntax for filters. Quotes are important, especially in Windows PowerShell. For example, use docker ps --filter "name=web" rather than docker ps --filter name=web.
Best Practices for Docker Container Management
Effective container listing is just one aspect of Docker container management. Here are some best practices to enhance your Docker workflow:
Naming Conventions
Always use meaningful names for your containers with the --name flag when creating them. This makes it much easier to identify containers when listing them:
docker run --name web-app-prod nginx
Consistent naming conventions make filtering and management much more straightforward.
Regular Cleanup
Periodically remove stopped containers to free up resources:
docker container prune
For more selective cleanup, use filtering to remove specific containers:
docker rm $(docker ps -a -f status=exited -f status=created -q)
Use Labels for Organization
Add metadata to your containers with labels, which can then be used for filtering:
docker run --label environment=production --label app=web nginx
Later, you can list containers by these labels:
docker ps --filter "label=environment=production"
Create Aliases for Common Commands
Set up shell aliases for frequently used docker ps commands:
alias dps='docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"'
This saves time and ensures consistent output formats across your team.
Simplify Your Docker Container Management
While command-line tools are powerful, managing containers at scale can be challenging. Try our Docker management dashboard to visualize and control all your containers from a single interface.
No credit card required. Start managing your containers visually today.
Conclusion: Mastering Docker Container Listing
Effectively listing and managing Docker containers is a fundamental skill for any developer or DevOps professional working with containerized applications. The docker ps command and its various options provide powerful tools for visibility into your Docker environment.
By mastering the techniques covered in this guide—from basic listing to advanced filtering and formatting—you'll be better equipped to monitor, troubleshoot, and manage your Docker containers efficiently.
Remember that container listing is just one aspect of Docker management. As your containerized applications grow in complexity, consider adopting additional tools and practices to maintain visibility and control over your Docker environment.
Frequently Asked Questions
How do I list all Docker containers regardless of their status?
Use docker ps -a or docker ps --all to list all containers, including those that are stopped or exited.
Can I list Docker containers by their IP addresses?
Docker ps doesn't directly show IP addresses. Use this command to list containers with their IPs:
docker ps -q | xargs -n 1 docker inspect --format '{{.Name}} - {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' | sed 's/\///'
How can I list only the most recently created containers?
Use docker ps -n [number] where [number] is how many recent containers you want to see. For example, docker ps -n 5 shows the 5 most recently created containers.
Is there a way to see the size of Docker containers?
Yes, use docker ps --size or docker ps -s to add a SIZE column to the output showing the disk space used by each container.
How do I list Docker containers that are using a specific volume?
Use the filter option with the volume parameter:
docker ps --filter volume=volume_name
Replace volume_name with the name of your volume.
Comments