mirror of
https://github.com/docker/docker-bench-security.git
synced 2025-01-18 16:22:33 +01:00
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:
parent
8ff1dc25ee
commit
e29a886254
1 changed files with 12 additions and 0 deletions
|
@ -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}')
|
||||
|
|
Loading…
Reference in a new issue