Only show number of running containers when there are any

This commit is contained in:
Michael Boelen 2016-07-30 14:01:36 +02:00
parent ad8c9f40ca
commit c8096dd06c
1 changed files with 3 additions and 3 deletions

View File

@ -139,7 +139,7 @@
DOCKER_CONTAINERS_TOTAL=0
fi
LogText "Result: docker info shows ${DOCKER_CONTAINERS_TOTAL} containers"
DOCKER_CONTAINERS_TOTAL2=`${DOCKERBINARY} ps -a 2> /dev/null | grep -v "CONTAINER" | wc -l`
DOCKER_CONTAINERS_TOTAL2=$(${DOCKERBINARY} ps -a 2> /dev/null | grep -c -v "CONTAINER")
LogText "Result: docker ps -a shows ${DOCKER_CONTAINERS_TOTAL2} containers"
if [ ! "${DOCKER_CONTAINERS_TOTAL}" = "${DOCKER_CONTAINERS_TOTAL2}" ]; then
LogText "Result: difference detected, which is unexpected"
@ -150,9 +150,9 @@
fi
# Check running instances
DOCKER_CONTAINERS_RUNNING=`${DOCKERBINARY} ps 2> /dev/null | grep -v "CONTAINER" | wc -l`
Display --indent 8 --text "- Running containers" --result "${DOCKER_CONTAINERS_RUNNING}" --color GREEN
DOCKER_CONTAINERS_RUNNING=$(${DOCKERBINARY} ps 2> /dev/null | grep -c -v "CONTAINER")
if [ ${DOCKER_CONTAINERS_RUNNING} -gt 0 ]; then
Display --indent 10 --text "- Running containers" --result "${DOCKER_CONTAINERS_RUNNING}" --color GREEN
LogText "Result: ${DOCKER_CONTAINERS_RUNNING} containers are currently active"
Report "docker_containers_running=${DOCKER_CONTAINERS_RUNNING}"
else