From 63b0c056558ef0f3346f6e704a3bb6712e763e71 Mon Sep 17 00:00:00 2001
From: Jan Semmelink <jan@uafrica.com>
Date: Tue, 19 Oct 2021 14:56:27 +0200
Subject: [PATCH] Stop and REMOVE old container

---
 mage_helpers/debug.go | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/mage_helpers/debug.go b/mage_helpers/debug.go
index 58ac652..929b154 100644
--- a/mage_helpers/debug.go
+++ b/mage_helpers/debug.go
@@ -117,7 +117,7 @@ func stopRunningSamDocker() {
 		panic(err)
 	}
 
-	containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{})
+	containers, err := cli.ContainerList(context.Background(), types.ContainerListOptions{All: true})
 	if err != nil {
 		panic(err)
 	}
@@ -139,7 +139,11 @@ func stopRunningSamDocker() {
 			if err != nil {
 				panic(err)
 			}
-			log.Printf("Stopped container %s\n", container.ID)
+			err = cli.ContainerRemove(context.Background(), container.ID, types.ContainerRemoveOptions{})
+			if err != nil {
+				panic(err)
+			}
+			log.Printf("Stopped and removed container %s\n", container.ID)
 		}
 	}
 
-- 
GitLab