diff --git a/docker_test.sh b/docker_test.sh index 101978c7e2f9777106de69c9b62a13c9a330a7c7..f1819cb1f06b6805df4d029e0c4c2c67907af09e 100755 --- a/docker_test.sh +++ b/docker_test.sh @@ -44,9 +44,10 @@ if [[ -d "$1" ]]; then # Go to the folder of the service which will be tested cd "$1" - echo -e "\n==== Stop and remove existing containers ====" create_dumb_secrets - docker-compose down + + echo -e "\n==== Stop and remove existing containers and volumes ====" + docker-compose down -v cd .. else echo "WARNING : directory does not exist ($1) ; will try to pull" @@ -82,9 +83,11 @@ done echo -e "\n==== Remove and re-create named external volumes ====" for v in $(docker-compose config --volumes); do - # Don't fail if volume does not exists - docker volume rm "$v" || true - docker volume create "$v" + if [ grep $v -A 1 docker-compose.yml | grep 'external' ]; then + # Don't fail if volume does not exists + docker volume rm "$v" || true + docker volume create "$v" + fi done echo -e "\n==== Remove old images ===="