Skip to content

Instantly share code, notes, and snippets.

@DerPauli
Last active November 3, 2020 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DerPauli/e44b7766ec6298dc997032afc076092f to your computer and use it in GitHub Desktop.
Save DerPauli/e44b7766ec6298dc997032afc076092f to your computer and use it in GitHub Desktop.
Delete docker images locally

For Unix

To delete all containers including its volumes use,

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

To delete all the images,

docker rmi -f $(docker images -a -q)

Remember, you should remove all the containers before removing all the images from which those containers were created.

For Windows

In case you are working on Windows (Powershell),

$images = docker images -a -q
foreach ($image in $images) { docker image rm $image -f }

Based on the comment from CodeSix, one liner for Window's Powershell,

docker images -a -q | % { docker image rm $_ -f }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment