diff --git a/tests/tox.sh b/tests/tox.sh index 8a79603fe..a43267c8d 100644 --- a/tests/tox.sh +++ b/tests/tox.sh @@ -48,7 +48,13 @@ bash "$WORKSPACE"/travis-builds/purge_cluster.sh containers_to_remove=$(docker ps -a -q) if [ "${containers_to_remove}" ]; then - docker rm -f "$@" "${containers_to_remove}" || echo failed to remove containers + ATTEMPTS=0 + NUM_CONTAINERS=$(docker ps -a -q | wc -l) + until [ $ATTEMPTS -eq 5 ] || [ $NUM_CONTAINERS -eq 0 ]; do + docker rm -f "$@" "${containers_to_remove}" + (( ATTEMPTS++ )) + NUM_CONTAINERS=$(docker ps -a -q | wc -l) + done fi cd "$WORKSPACE"