Created
November 8, 2016 16:14
-
-
Save lagner/47a24ac63f0698d6513ee6764f97ea62 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env groovy | |
images = 'docker images -a'.execute().text | |
images.tokenize('\n').eachWithIndex { line, it -> | |
if (it == 0) { | |
// first line is table header | |
return | |
} | |
def parts = line.tokenize(" ").collect { it.trim() } | |
def (rep, tag, id) = parts | |
if (rep != '<none>') { | |
def reply = System.console().readLine "remove ${id} - ${rep}:${tag}?[y to remove]: " | |
if (reply != 'y') { | |
return | |
} | |
} | |
def out = "docker rmi -f ${id}".execute().text | |
if (out?.trim()) { | |
print out | |
println "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment