mirror of
https://github.com/containrrr/watchtower.git
synced 2025-12-15 14:40:13 +01:00
Try to stop before kill
This commit is contained in:
parent
76f9cea516
commit
90a8b2a709
1 changed files with 7 additions and 1 deletions
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue