From a89d72b5ebcdf2e757641e4ffe4d28b4094f4222 Mon Sep 17 00:00:00 2001 From: fahlke Date: Fri, 7 Jul 2017 07:26:11 +0200 Subject: [PATCH] Resolves prometheus/node_exporter#585 (#586) * Resolves prometheus/node_exporter#585 * - removed 'docker rm' as it is not allowed on CircleCI See discussion: https://discuss.circleci.com/t/docker-error-removing-intermediate-container/70 --- test_image.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/test_image.sh b/test_image.sh index c23523a4..4b47854d 100755 --- a/test_image.sh +++ b/test_image.sh @@ -4,20 +4,27 @@ set -exo pipefail docker_image=$1 port=$2 +container_id='' + wait_start() { for in in {1..10}; do - if /usr/bin/curl -s -m 5 -f "http://localhost:${port}/metrics" > /dev/null ; then exit 0 ; - else - sleep 1 - fi + if /usr/bin/curl -s -m 5 -f "http://localhost:${port}/metrics" > /dev/null; then + docker_cleanup + exit 0 + else + sleep 1 + fi done - exit 1 - + exit 1 } docker_start() { - docker run -d -p "${port}":"${port}" "${docker_image}" + container_id=$(docker run -d -p "${port}":"${port}" "${docker_image}") +} + +docker_cleanup() { + docker kill "${container_id}" } if [[ "$#" -ne 2 ]] ; then