Skip to content

Instantly share code, notes, and snippets.

@samuel-begin
Last active April 3, 2019 12:55
Show Gist options
  • Save samuel-begin/8b74a7d2e29b2e24ddec5c2d851a40e7 to your computer and use it in GitHub Desktop.
Save samuel-begin/8b74a7d2e29b2e24ddec5c2d851a40e7 to your computer and use it in GitHub Desktop.
How to remove docker images based on pattern with windows cmd

first identify your images, because we are gonna force delete them. be sure to have the appropriate filter pattern with list

docker image ls -f "reference=prefix*"

then, when you are sure that you have the appropriate filter, use it in the following foreach. It will run a docker rm -f on the id of each image your filter will return

for /F "tokens=*" %i in ('docker image ls -qf "reference=prefix*"') do docker image rm -f %i

and dont forget to prune in order to reclaim your disk space!

docker system prune
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment