From 75e9a9e7ebf9040d6323d25b241ad2aedc61b9c6 Mon Sep 17 00:00:00 2001
From: Jan Semmelink <jan@uafrica.com>
Date: Mon, 11 Oct 2021 09:06:59 +0200
Subject: [PATCH] Implemented a fix

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

diff --git a/mage_helpers/debug.go b/mage_helpers/debug.go
index ff6e2b4..3d07d6c 100644
--- a/mage_helpers/debug.go
+++ b/mage_helpers/debug.go
@@ -111,7 +111,7 @@ func runLongRunningSubProcess(ctx context.Context, name string, arg ...string) e
 }
 
 func stopRunningSamDocker() {
-	cli, err := client.NewEnvClient()
+	cli, err := client.NewClientWithOpts(client.FromEnv)
 	if err != nil {
 		panic(err)
 	}
@@ -122,14 +122,24 @@ func stopRunningSamDocker() {
 	}
 
 	for _, container := range containers {
-		for _, port := range container.Ports {
-			if port.PrivatePort == 5986 {
-				err = cli.ContainerStop(context.Background(), container.ID, nil)
-				if err != nil {
-					panic(err)
+		mustStop := false
+		if container.Command == "/var/rapid/aws-lambda-rie" {
+			mustStop = true
+		} else {
+			for _, port := range container.Ports {
+				if port.PrivatePort == 5986 {
+					mustStop = true
+					break
 				}
 			}
 		}
+		if mustStop {
+			err = cli.ContainerStop(context.Background(), container.ID, nil)
+			if err != nil {
+				panic(err)
+			}
+			log.Printf("Stopped container %s\n", container.ID)
+		}
 	}
 
 }
-- 
GitLab