DEV Community

Weerayut Teja
Weerayut Teja

Posted on

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.

Top comments (0)