From 00a1270c9b30f08715acf23d989f0b3d9f3f6175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sj=C3=B6gren?= Date: Tue, 22 Dec 2015 19:46:32 +0100 Subject: [PATCH] inspect output changed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Sjögren --- tests/5_container_runtime.sh | 24 +++++++++++++++++++++--- tests/6_docker_security_operations.sh | 8 +++++++- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tests/5_container_runtime.sh b/tests/5_container_runtime.sh index cf24d72..a77d7eb 100644 --- a/tests/5_container_runtime.sh +++ b/tests/5_container_runtime.sh @@ -151,7 +151,13 @@ else /usr' fail=0 for c in $containers; do - volumes=$(docker inspect --format '{{ .VolumesRW }}' "$c") + docker inspect --format '{{ .VolumesRW }}' "$c" 2>/dev/null 1>&2 + + if [ $? -eq 0 ]; then + volumes=$(docker inspect --format '{{ .VolumesRW }}' "$c") + else + volumes=$(docker inspect --format '{{ .Mounts }}' "$c") + fi # Go over each directory in sensitive dir and see if they exist in the volumes for v in $sensitive_dirs; do sensitive=0 @@ -264,7 +270,13 @@ else fail=0 for c in $containers; do - memory=$(docker inspect --format '{{ .Config.Memory }}' "$c") + docker inspect --format '{{ .Config.Memory }}' "$c" 2> /dev/null 1>&2 + + if [ "$?" -eq 0 ]; then + memory=$(docker inspect --format '{{ .Config.Memory }}' "$c") + else + memory=$(docker inspect --format '{{ .HostConfig.Memory }}' "$c") + fi if [ "$memory" = "0" ]; then # If it's the first container, fail the test @@ -287,7 +299,13 @@ else fail=0 for c in $containers; do - shares=$(docker inspect --format '{{ .Config.CpuShares }}' "$c") + docker inspect --format '{{ .Config.CpuShares }}' "$c" 2> /dev/null 1>&2 + + if [ "$?" -eq 0 ]; then + shares=$(docker inspect --format '{{ .Config.CpuShares }}' "$c") + else + shares=$(docker inspect --format '{{ .HostConfig.CpuShares }}' "$c") + fi if [ "$shares" = "0" ]; then # If it's the first container, fail the test diff --git a/tests/6_docker_security_operations.sh b/tests/6_docker_security_operations.sh index c895dfb..27c3840 100644 --- a/tests/6_docker_security_operations.sh +++ b/tests/6_docker_security_operations.sh @@ -15,7 +15,13 @@ else set -f; IFS=$' ' for c in $containers; do - volumes=$(docker inspect --format '{{ .Volumes }}' "$c") + docker inspect --format '{{ .Volumes }}' "$c" 2>/dev/null 1>&2 + + if [ $? -eq 0 ]; then + volumes=$(docker inspect --format '{{ .Volumes }}' "$c") + else + volumes=$(docker inspect --format '{{ .Config.Volumes }}' "$c") + fi if [ "$volumes" = "map[]" ]; then # If it's the first container, fail the test