All questions

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-app

Edited by Jack · joysait@rediffmail.com

Add a Q&A

Drop an image here or click to choose. It is saved as images/N.ext.

Live preview

Publish to GitHub

Drafts 0

Drafts live in this browser only. Download or push them to make them public.

    Files to commit

    data/qa.json
    sitemap.xml
    robots.txt

    Push with the GitHub API

    Uses a fine-grained token with Contents: Read and write on your repo. The token stays in this page's memory only: it is never saved or sent anywhere except api.github.com.