mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Allow to kill container after docker server restarts
This commit is contained in:
parent
82848d4158
commit
d440782e17
1 changed files with 4 additions and 1 deletions
|
@ -614,7 +614,7 @@ func (container *Container) monitor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) kill() error {
|
func (container *Container) kill() error {
|
||||||
if !container.State.Running || container.cmd == nil {
|
if !container.State.Running {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -626,6 +626,9 @@ func (container *Container) kill() error {
|
||||||
|
|
||||||
// 2. Wait for the process to die, in last resort, try to kill the process directly
|
// 2. Wait for the process to die, in last resort, try to kill the process directly
|
||||||
if err := container.WaitTimeout(10 * time.Second); err != nil {
|
if err := container.WaitTimeout(10 * time.Second); err != nil {
|
||||||
|
if container.cmd == nil {
|
||||||
|
return fmt.Errorf("lxc-kill failed, impossible to kill the container %s", container.Id)
|
||||||
|
}
|
||||||
log.Printf("Container %s failed to exit within 10 seconds of lxc SIGKILL - trying direct SIGKILL", container.Id)
|
log.Printf("Container %s failed to exit within 10 seconds of lxc SIGKILL - trying direct SIGKILL", container.Id)
|
||||||
if err := container.cmd.Process.Kill(); err != nil {
|
if err := container.cmd.Process.Kill(); err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue