Posted by Arjun Arjun on Tuesday 12th January 2021, 1 minute read

How to remove all docker containers and images using PowerShell?

The docker system prune command removes all stopped containers, dangling images, and unused networks and if we pass the --volumes option we can 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}
...
Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.