List Containers

List running or all containers.

container
monitoring

Command

docker ps

Explanation

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 ps

List all containers, including stopped ones

docker ps -a