Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function docker-rmi-none() {
for i in `docker-images-none-cids`; do
echo $i
#local cid=$(docker-cid "$i")
#[ "$cid" != "" ] &&
local pid=$(docker-pid "$i" 2>/dev/null)
[ "$pid" != "" ] && echo "-------- Cleaning the stopped container: $i, $pid" && docker rm -f $pid
[ "$i" != "" ] && echo "-------- Erasing the container: $i, $pid" && docker rmi -f $i
done
}
function docker-images-none-cids() {
docker images | grep -Ei "<none>" | grep -Eio " ([0-9a-f]{12}) "
}
function docker-cid() {
CID=$(docker ps | grep -Eoi "^[0-9a-f]+[ \t]+$1" | grep -Eoi "^[0-9a-f]+")
[ "$CID" != "" ] && echo $CID || echo $1
}
alias docker-pid="docker inspect --format ''"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment