warn if only -lt half of the images are in use

Signed-off-by: Thomas Sjögren <konstruktoid@users.noreply.github.com>
This commit is contained in:
Thomas Sjögren 2015-06-01 22:37:28 +02:00
parent 8ff1dc25ee
commit e29a886254

View file

@ -37,6 +37,14 @@ set +f; unset IFS
# 6.6
check_6_6="6.6 - Avoid image sprawl"
images=$(docker images -q | wc -l | awk '{print $1}')
active_images=0
for c in $(docker inspect -f "{{.Image}}" $(docker ps -qa)); do
if [[ $(docker images --no-trunc -a | grep $c) ]]; then
((active_images++))
fi
done
if [ "$images" -gt 100 ]; then
warn "$check_6_6"
warn " * There are currently: $images images"
@ -45,6 +53,10 @@ else
info " * There are currently: $images images"
fi
if [[ "$active_images" -lt "$((images / 2))" ]]; then
warn " * Only $active_images out of $images are in use"
fi
# 6.7
check_6_7="6.7 - Avoid container sprawl"
total_containers=$(docker info 2>/dev/null | grep "Containers" | awk '{print $2}')