DEV Community

Weerayut Teja
Weerayut Teja

Posted on

2 2

How to Delete All Docker Images Using Powershell

There are a plenty of Shell Commands on how to delete all docker images in single command.

But really hard to find command for Windows.

Thanks to mastroiannim the contributor in This Gist.

TLDR

docker images -aq | foreach {docker rmi $_ -f}
Enter fullscreen mode Exit fullscreen mode

How it works?

It combines of two commands.

docker images -aq
Enter fullscreen mode Exit fullscreen mode

This command returns ID(s) of all images one ID per line. And we combine with below command to loop throught each line and using Docker Image ID as argument.

foreach {docker rmi $_ -f}
Enter fullscreen mode Exit fullscreen mode

So, we run both two command in the single line.

docker images -aq | foreach {docker rmi $_ -f}
Enter fullscreen mode Exit fullscreen mode

Hope this post has some benefit for you.

Reinvent your career. Join DEV.

It takes one minute and is worth it for your career.

Get started

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay