How do I list and remove all stopped Docker containers?
Answer
List stopped containers with a status filter, then remove them with `docker container prune`. Prune asks for confirmation unless you pass `-f`.
Images and volumes are separate: `docker image prune` and `docker volume prune` clean those, and a volume prune deletes data, so check first.
Bash solution
# list stopped containers
docker ps -a --filter "status=exited"
# remove all stopped containers (asks first)
docker container prune
# same, no prompt (useful in scripts)
docker container prune -f
# remove one container by name
docker rm my-old-appEdited by Jack · joysait@rediffmail.com