X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Ffunctest%2Ffunctest-cleanup.sh;h=c21b543a62789e28542f0b424e58b253dd63efde;hb=6ccbd752d0adff4f62d22586b237857fe86fc58a;hp=f8140e058c101f0e1b7751b307affbbdf115eeea;hpb=ea3e7ce34d53dceef7fae88dd82c0c52febb556c;p=releng.git diff --git a/jjb/functest/functest-cleanup.sh b/jjb/functest/functest-cleanup.sh index f8140e058..c21b543a6 100755 --- a/jjb/functest/functest-cleanup.sh +++ b/jjb/functest/functest-cleanup.sh @@ -4,13 +4,17 @@ echo "Cleaning up docker containers/images..." FUNCTEST_IMAGE=opnfv/functest -# Remove containers along with image opnfv/functest: -dangling_images=($(docker images -f "dangling=true" | grep $FUNCTEST_IMAGE | awk '{print $1}')) + +# Remove containers along with image opnfv/functest*: +dangling_images=($(docker images -f "dangling=true" | grep $FUNCTEST_IMAGE | awk '{print $3}')) if [[ -n ${dangling_images} ]]; then echo " Removing $FUNCTEST_IMAGE: images and their containers..." for image_id in "${dangling_images[@]}"; do echo " Removing image_id: $image_id and its containers" - docker ps -a | grep $image_id | awk '{print $1}'| xargs docker rm -f >${redirect} + containers=$(docker ps -a | grep $image_id | awk '{print $1}') + if [[ -n "$containers" ]];then + docker rm -f $containers >${redirect} + fi docker rmi $image_id >${redirect} done fi