diff --git a/include/tests_containers b/include/tests_containers index dcd4d238..ce350aee 100644 --- a/include/tests_containers +++ b/include/tests_containers @@ -119,6 +119,9 @@ # Check total of containers logtext "Test: checking total amount of Docker containers" DOCKER_CONTAINERS_TOTAL=`${DOCKERBINARY} info 2> /dev/null | grep "^Containers: " | awk '{ print $2 }'` + if [ ${DOCKER_CONTAINERS_TOTAL} -z ]; then + 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` logtext "Result: docker ps -a shows ${DOCKER_CONTAINERS_TOTAL2} containers" @@ -131,7 +134,7 @@ fi # Check running instances - DOCKER_CONTAINERS_RUNNING=`${DOCKERBINARY} ps | grep -v "CONTAINER" | wc -l` + 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 if [ ${DOCKER_CONTAINERS_RUNNING} -gt 0 ]; then logtext "Result: ${DOCKER_CONTAINERS_RUNNING} containers are currently active"