DEV Community

loading...

How to Delete All Docker Images Using Powershell

Weerayut Teja
Full-Stack Web Developer. I really have passionate about building beautiful & functional websites.
・1 min read

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.

Discussion (0)