From 90a8b2a7092d58022bed360d7716e1a2511c471f Mon Sep 17 00:00:00 2001 From: xhiena Date: Mon, 14 Apr 2025 08:53:12 +0200 Subject: [PATCH] Try to stop before kill --- pkg/container/client.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/container/client.go b/pkg/container/client.go index c6c37de..bad1cc5 100644 --- a/pkg/container/client.go +++ b/pkg/container/client.go @@ -193,7 +193,13 @@ func (client dockerClient) StopContainer(c t.Container, timeout time.Duration) e if c.IsRunning() { log.Infof("Stopping %s (%s) with %s", c.Name(), shortID, signal) - if err := client.api.ContainerKill(bg, idStr, signal); err != nil { + var maxWaitSeconds int = int(timeout.Milliseconds()) + stopOptions := container.StopOptions{ + Signal: "", + Timeout: &maxWaitSeconds, + } + log.Infof("Stopping %s (%s) with %s, Timeout: %i", c.Name(), shortID, signal, maxWaitSeconds) + if err := client.api.ContainerStop(bg, idStr, stopOptions); err != nil { return err } }