Skip to content

Instantly share code, notes, and snippets.

@A-725-K
Created August 29, 2021 15:24
Show Gist options
  • Save A-725-K/f764ca18e7b4be9d9a99d97649ed3ee3 to your computer and use it in GitHub Desktop.
Save A-725-K/f764ca18e7b4be9d9a99d97649ed3ee3 to your computer and use it in GitHub Desktop.
Utility to clean all the <none> images accumulated in docker
#!/bin/bash
images=$(docker image ls | tail +2 | grep '<none>' | awk '{print $3}')
echo -e "*** This script will remove the following <none> images: ***\n\n$images\n"
read -p 'Are you sure? [y/N] ' choice
if [[ $choice == "y" ]] || [[ $choice == "Y" ]]; then
echo -e "\nRemoving the images"
docker image rm $images
else
echo -e "\nAborting the operation..."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment