mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
Wait for container stop after kill
This commit is contained in:
parent
13ec7ac94e
commit
1f460997cb
2 changed files with 32 additions and 0 deletions
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/samalba/dockerclient"
|
||||
)
|
||||
|
@ -104,6 +105,22 @@ func (client DockerClient) Stop(c Container) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Wait for container to exit, but proceed anyway after 10 seconds
|
||||
timeout := time.After(10 * time.Second)
|
||||
PollLoop:
|
||||
for {
|
||||
select {
|
||||
case <-timeout:
|
||||
break PollLoop
|
||||
default:
|
||||
ci, err := client.api.InspectContainer(c.containerInfo.Id)
|
||||
if err != nil || !ci.State.Running {
|
||||
break PollLoop
|
||||
}
|
||||
time.Sleep(1 * time.Second)
|
||||
}
|
||||
}
|
||||
|
||||
return client.api.RemoveContainer(c.containerInfo.Id, true, false)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue