Docker Image Cleanup

By | November 19, 2019

Here is a bash script to cleanup images on a build server:

#!/bin/bash

sudo docker image rm -f $(sudo docker image ls | grep 'your_image_name' | awk '{ print $3 }')
sudo docker images -q -f dangling=true | xargs -r sudo docker rmi -f

Hope it helps. 🙂