Skip to content

Commit

Permalink
Updated bashrc to check if there are removable images or volumes when
Browse files Browse the repository at this point in the history
doing docker cleanups
  • Loading branch information
szabolcsmaj committed Sep 12, 2016
1 parent b010dc7 commit de61f5b
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions .bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,21 @@ function askForSomething() {
done
}
function removeDanglingImages() {
askForSomething "docker images -q -f \"dangling=true\" | xargs docker rmi"
IMAGE_COUNT=$(docker images -q -f \"dangling=true\" | wc -l)
if [[ $IMAGE_COUNT -gt 0 ]]; then
askForSomething "docker images -q -f \"dangling=true\" | xargs docker rmi"
else
echo "There are no dangling images"
fi
}

function removeDanglingVolumes() {
askForSomething "docker volume ls -q -f dangling=true | xargs docker volume rm"
VOLUME_COUNT=$(docker volume ls -q -f \"dangling=true\" | wc -l)
if [[ $VOLUME_COUNT -gt 0 ]]; then
askForSomething "docker volume ls -q -f dangling=true | xargs docker volume rm"
else
echo "There are no dangling volumes"
fi
}
#Path settings
export PATH="$PATH:~/.local/bin"
Expand Down

0 comments on commit de61f5b

Please sign in to comment.