From f9aab50255cbdec0a9ae8266855d727f9c820b6e Mon Sep 17 00:00:00 2001
From: Quentin Duchemin <quentinduchemin@tuta.io>
Date: Tue, 9 Jun 2020 22:33:10 +0200
Subject: [PATCH] [docker_test.sh] Fix logic for external volumes

---
 docker_test.sh | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/docker_test.sh b/docker_test.sh
index 101978c7..f1819cb1 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 ===="
-- 
GitLab