To list all Docker containers (including stopped ones), use:
docker ps -aThis command shows both running and exited containers, helping you manage the full container lifecycle.
Quick Command Reference
| Task | Command |
|---|---|
| List all containers | docker ps -a |
| List running containers | docker ps |
| List stopped containers | docker ps -f "status=exited" |
| Filter by name | docker ps -a --filter "name=<name>" |
| Show only container IDs | docker ps -aq |
Understanding docker ps vs docker ps -a
Difference between running and stopped containers
docker psshows only running containersdocker ps -ashows all containers, including stopped ones- Stopped containers can be inspected, restarted, or removed
If you need to restart stopped containers, refer to restart docker container.
Common Ways to Use docker ps -a
Method 1: List all containers (basic usage)
docker ps -aThis displays all containers along with their status, names, and IDs. You can then take further actions like stopping or removing containers. For example, you can
stop all docker containers if required.
Method 2: Show only stopped containers
docker ps -f "status=exited"This helps identify containers that have completed execution or failed.
To clean up unused containers, refer to remove unused docker containers.
Method 3: Filter containers by name or status
docker ps -a --filter "name=<name>"You can also filter by status, image, or other parameters to narrow down results.
If you are troubleshooting containers, you may also want to check logs using docker logs.
Understanding docker ps -a Output
Key columns explained (CONTAINER ID, STATUS, NAMES)
- CONTAINER ID → Unique identifier for each container
- IMAGE → Docker image used to create the container
- COMMAND → Command executed when the container started
- STATUS → Current state (e.g., Up, Exited, Restarting)
- PORTS → Port mappings between host and container
- NAMES → Human-readable container name
If a container shows as Exited, it means the main process has stopped. You can inspect logs using docker logs to identify the issue.
Best Practices for Managing Containers
- Regularly check container status using
docker ps -a - Remove unused containers to free up resources
- Use meaningful names for easier identification (see rename docker container)
- Restart stopped containers when needed (refer to docker restart container)
- Monitor logs for debugging and performance issues
For better cleanup and resource management, you can also remove unused docker containers.
Frequently Asked Questions
1. What does docker ps -a do?
docker ps -a lists all Docker containers, including running and stopped ones.2. How is docker ps different from docker ps -a?
docker ps shows only running containers, while docker ps -a shows all containers.3. Can I filter docker ps -a output?
Yes, you can use filters like status, name, and ancestor to refine the output.4. Why are some containers shown as exited?
Containers are shown as exited when their main process has completed or stopped.Conclusion
The docker ps -a command is essential for viewing and managing all containers, including those that are stopped. By understanding its output and using filters effectively, you can improve container visibility and control across your Docker environment.
To perform actions on containers, you may also find it useful to stop all docker containers or keep docker container running depending on your use case.
Official Documentation
For more details, refer to the official Docker documentation:









