DEV Community

gie3d
gie3d

Posted on

Remove Docker Images according to a pattern

docker images -a | grep pattern | awk '{print $3}' | xargs docker rmi -f
Enter fullscreen mode Exit fullscreen mode

docker images -a to list all the images you have

| grep pattern will filter only the lines that contains your pattern (such as | grep node will filter images which contains node in its name)

awk '{print $3}' will extract the third column and print it out

xargs docker rmi -f will use the output of awk '{print $3}' as a parameter of docker rmi -f (which is a remove image command'

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay