docker remove all stopped containers

# Remove all stopped containers (with confirmation prompt)
docker container prune

# Remove all stopped containers without confirmation
docker container prune -f

# Or remove specific containers
docker rm container1 container2

Stopped containers accumulate and waste disk space. Clean them up regularly.

List stopped containers first

# Show only stopped containers
docker ps -a --filter "status=exited"

# Show container IDs only (for piping)
docker ps -a -q --filter "status=exited"

Remove all stopped containers with xargs

docker ps -a -q --filter "status=exited" | xargs docker rm

Remove containers AND their volumes

docker rm -v my-container
# -v also removes anonymous volumes attached to the container

Remove everything unused (containers, images, networks, cache)

docker system prune -a