mirror of
https://github.com/moby/moby.git
synced 2025-12-06 07:41:18 +03:00
Signal to stop a container.
Allow to set the signal to stop a container in `docker run`: - Use `--stop-signal` with docker-run to set the default signal the container will use to exit. Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
@@ -315,3 +315,19 @@ func (s *DockerSuite) TestRunWithSwappinessInvalid(c *check.C) {
|
||||
c.Fatalf("failed. test was able to set invalid value, output: %q", out)
|
||||
}
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestStopContainerSignal(c *check.C) {
|
||||
out, _ := dockerCmd(c, "run", "--stop-signal", "SIGUSR1", "-d", "busybox", "/bin/sh", "-c", `trap 'echo "exit trapped"; exit 0' USR1; while true; do sleep 1; done`)
|
||||
containerID := strings.TrimSpace(out)
|
||||
|
||||
if err := waitRun(containerID); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
dockerCmd(c, "stop", containerID)
|
||||
out, _ = dockerCmd(c, "logs", containerID)
|
||||
|
||||
if !strings.Contains(out, "exit trapped") {
|
||||
c.Fatalf("Expected `exit trapped` in the log, got %v", out)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user