Last active
January 31, 2021 15:57
-
-
Save kbaynes/9a3da6cd24fbefacf3afe0046f4380c6 to your computer and use it in GitHub Desktop.
Remove Docker image where tag is <none>
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/env bash | |
# Use: remove docker images where tag is "<none>" | |
# uses unix pipes | |
# command parts explained: | |
# docker images : list all of the images in Docker. Each line looks like: | |
# "maven 3.6.3-adoptopenjdk-11 b6e818035058 10 days ago 540MB" | |
# grep "<none>": show only lines that contain string <none>. Could be any string on the line. | |
# awk '{print $3}' : use the text processor 'awk' to split each line into columns using | |
# spaces and print the third colum (the docker image id, like 'b6e818035058' above) | |
# xargs docker image rm : use the xargs app to pass the result into the command 'docker image rm <piped value>'. | |
# Converts to 'docker image rm b6e818035058' | |
docker images | grep "<none>" | awk '{print $3}' | xargs docker image rm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment