Command
docker psExplanation
docker ps shows details of running containers by default. With -a, it includes stopped and exited containers. Common flags include -q for only container IDs and --filter for filtering results.
Common Use Cases
- •Monitor running containers
- •Check container IDs for scripting
- •Audit stopped containers
Best Practices
- ✓Use docker ps -a regularly to clean unused containers
- ✓Combine with docker rm $(docker ps -aq) for cleanup
Common Mistakes to Avoid
- ⚠Forgetting the -a flag and missing stopped containers
Troubleshooting
Problem: Container not showing in list
Solution: Use -a flag to include stopped containers.
Examples
List running containers
docker psList all containers, including stopped ones
docker ps -a