Skip to content

How to remove all docker containers and images using PowerShell?

Last updated on November 17, 2022

The docker system prune command removes all stopped containers, dangling images, and unused networks. If you pass the --volumes flag, it will remove all unused volumes too.

docker system prune
docker system prune --volumes

You can execute the below commands in PowerShell to remove all the images and docker containers.

Remove all containers:

docker ps -a -q | % { docker rm $_ } 

Remove all images

docker images -q | % { docker rmi $_ }

Remove all the version of the image if the image name contains given text:

docker images --format='{{json .}}'|Select-String -Pattern "${imageName}" |   ConvertFrom-Json |  ForEach-Object -process { docker rmi -f $_.ID}
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments