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