Created
May 19, 2023 15:30
-
-
Save mjovanc/8f9d0e1bcb77dea611f0dd6bbb55b862 to your computer and use it in GitHub Desktop.
Removes all Docker Images that has <none> set on repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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