mirror of
https://github.com/containrrr/watchtower.git
synced 2026-01-03 07:38:49 +01:00
fix: attempt to gracefully stop containers (#237)
This commit is contained in:
parent
ee8f293f47
commit
1a9a50b755
1 changed files with 3 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue