From 3b0aac27780fcc1c63f6277d610622567a6778e5 Mon Sep 17 00:00:00 2001 From: anthonyvallone Date: Thu, 16 Feb 2023 13:28:57 +1100 Subject: [PATCH] fix: attempt to gracefully stop containers (#237) --- pkg/container/client.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/container/client.go b/pkg/container/client.go index edcd3d1..c660e16 100644 --- a/pkg/container/client.go +++ b/pkg/container/client.go @@ -177,8 +177,13 @@ func (client dockerClient) StopContainer(c Container, timeout time.Duration) err shortID := c.ID().ShortID() if c.IsRunning() { - log.Infof("Stopping %s (%s) with %s", c.Name(), shortID, signal) - if err := client.api.ContainerStop(bg, idStr, c.StopOptions{ Signal: "SIGKILL", Timeout: &timeout,}); 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 } }