1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #4684 from cpuguy83/4682-do_not_sigkill_on_docker_stop

Disable automatic killing of containers when docker stop fails
This commit is contained in:
Guillaume J. Charmes 2014-03-18 11:28:42 -07:00
commit bfbf338f51
4 changed files with 10 additions and 18 deletions

View file

@ -497,8 +497,8 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
}
func (cli *DockerCli) CmdStop(args ...string) error {
cmd := cli.Subcmd("stop", "[OPTIONS] CONTAINER [CONTAINER...]", "Stop a running container (Send SIGTERM, and then SIGKILL after grace period)")
nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Number of seconds to wait for the container to stop before killing it.")
cmd := cli.Subcmd("stop", "[OPTIONS] CONTAINER [CONTAINER...]", "Stop a running container (Send SIGTERM)")
nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Number of seconds to wait for the container to stop.")
if err := cmd.Parse(args); err != nil {
return nil
}
@ -525,7 +525,7 @@ func (cli *DockerCli) CmdStop(args ...string) error {
func (cli *DockerCli) CmdRestart(args ...string) error {
cmd := cli.Subcmd("restart", "[OPTIONS] CONTAINER [CONTAINER...]", "Restart a running container")
nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default=10")
nSeconds := cmd.Int([]string{"t", "-time"}, 10, "Number of seconds to wait for the container to stop. Default=10")
if err := cmd.Parse(args); err != nil {
return nil
}

View file

@ -432,7 +432,7 @@ Stop a container
HTTP/1.1 204 OK
:query t: number of seconds to wait before killing the container
:query t: number of seconds to wait for the container to stop
:statuscode 204: no error
:statuscode 404: no such container
:statuscode 500: server error
@ -457,7 +457,7 @@ Restart a container
HTTP/1.1 204 OK
:query t: number of seconds to wait before killing the container
:query t: number of seconds to wait for the container to stop
:statuscode 204: no error
:statuscode 404: no such container
:statuscode 500: server error

View file

@ -1371,11 +1371,11 @@ This example shows 5 containers that might be set up to test a web application c
Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
Stop a running container (Send SIGTERM, and then SIGKILL after grace period)
Stop a running container (Send SIGTERM)
-t, --time=10: Number of seconds to wait for the container to stop before killing it.
-t, --time=10: Number of seconds to wait for the container to stop.
The main process inside the container will receive SIGTERM, and after a grace period, SIGKILL
The main process inside the container will receive SIGTERM.
.. _cli_tag:

View file

@ -906,20 +906,12 @@ func (container *Container) Stop(seconds int) error {
// 1. Send a SIGTERM
if err := container.KillSig(15); err != nil {
utils.Debugf("Error sending kill SIGTERM: %s", err)
log.Print("Failed to send SIGTERM to the process, force killing")
if err := container.KillSig(9); err != nil {
return err
}
return err
}
// 2. Wait for the process to exit on its own
if err := container.WaitTimeout(time.Duration(seconds) * time.Second); err != nil {
log.Printf("Container %v failed to exit within %d seconds of SIGTERM - using the force", container.ID, seconds)
// 3. If it doesn't, then send SIGKILL
if err := container.Kill(); err != nil {
return err
}
return err
}
return nil
}