Salim Fadhley
Salim Fadhley

Reputation: 8195

Delete all the stopped containers (on Windows)?

On Linux I can delete all of the stopped containers with this handy one-liner:

$ docker rm $(docker ps -a -q)

It's documented here: Remove all stopped containers

But what's the equivalent syntax for Windows?

Upvotes: 3

Views: 2039

Answers (2)

thaJeztah
thaJeztah

Reputation: 28997

You can use docker container prune to remove all stopped containers (or docker system prune to cleanup other unused resources, such as unused networks, unused images, etc.

More information can be found in the reference documentation for this command

Upvotes: 9

Anar Mammad
Anar Mammad

Reputation: 60

In CMD terminal you can run:

FOR /f "tokens=*" %i IN ('docker ps -aq') DO docker rm %i

In Powershell terminal you can run:

docker ps -aq | % { docker rm $_ }

In Git Bash terminal you can run:

docker rm $(docker ps -aq)

Upvotes: 0

Related Questions