Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjovanc/8f9d0e1bcb77dea611f0dd6bbb55b862 to your computer and use it in GitHub Desktop.
Save mjovanc/8f9d0e1bcb77dea611f0dd6bbb55b862 to your computer and use it in GitHub Desktop.
Removes all Docker Images that has <none> set on repository
#!/bin/bash
# Get a list of all Docker images with "<none>" tag
image_list=$(docker images --format "{{.Repository}}:{{.Tag}} {{.ID}}" | grep "<none>")
# Loop through the images and remove them
while IFS= read -r image; do
image_id=$(echo $image | awk '{print $2}')
echo "Removing image: $image_id"
docker rmi $image_id
done <<< "$image_list"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment