diff --git a/mage_helpers/debug.go b/mage_helpers/debug.go index ff6e2b47c33f1d239a38a4153523534686841a00..3d07d6c42d948a60aaeff8c707e5839177759822 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) + } } }