From 1a9a50b755d3454ce5b44e4ba3416f92ba79bc7d Mon Sep 17 00:00:00 2001 From: anthonyvallone Date: Fri, 10 Feb 2023 12:07:03 +1100 Subject: [PATCH] fix: attempt to gracefully stop containers (#237) --- pkg/container/client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/container/client.go b/pkg/container/client.go index 7447828..edcd3d1 100644 --- a/pkg/container/client.go +++ b/pkg/container/client.go @@ -178,13 +178,14 @@ func (client dockerClient) StopContainer(c Container, timeout time.Duration) err if c.IsRunning() { log.Infof("Stopping %s (%s) with %s", c.Name(), shortID, signal) - if err := client.api.ContainerKill(bg, idStr, signal); err != nil { + if err := client.api.ContainerStop(bg, idStr, c.StopOptions{ Signal: "SIGKILL", Timeout: &timeout,}); err != nil { return err } } // TODO: This should probably be checked. - _ = client.waitForStopOrTimeout(c, timeout) + // ContainerStop has been implemented above with a SIGKILL if timeout is reached. This is no longer required + // _ = client.waitForStopOrTimeout(c, timeout) if c.containerInfo.HostConfig.AutoRemove { log.Debugf("AutoRemove container %s, skipping ContainerRemove call.", shortID)