From a252516ec19c9c83055a882da894712f2e812ecc Mon Sep 17 00:00:00 2001 From: David Calavera Date: Fri, 12 Feb 2016 17:56:40 -0500 Subject: [PATCH] Inherit StopSignal from Dockerfile. Make sure the image configuration is not overriden by the default value in the `create` flag. Signed-off-by: David Calavera --- daemon/commit.go | 4 ++++ integration-cli/docker_cli_build_test.go | 13 ++++++++++--- runconfig/opts/parse.go | 4 +++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/daemon/commit.go b/daemon/commit.go index 6f2b38d52d..d2de9b126d 100644 --- a/daemon/commit.go +++ b/daemon/commit.go @@ -89,6 +89,10 @@ func merge(userConf, imageConf *containertypes.Config) error { userConf.Volumes[k] = v } } + + if userConf.StopSignal == "" { + userConf.StopSignal = imageConf.StopSignal + } return nil } diff --git a/integration-cli/docker_cli_build_test.go b/integration-cli/docker_cli_build_test.go index 15df05f191..06754e01a4 100644 --- a/integration-cli/docker_cli_build_test.go +++ b/integration-cli/docker_cli_build_test.go @@ -5777,14 +5777,21 @@ func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *check.C) { func (s *DockerSuite) TestBuildStopSignal(c *check.C) { testRequires(c, DaemonIsLinux) - name := "test_build_stop_signal" - _, err := buildImage(name, + imgName := "test_build_stop_signal" + _, err := buildImage(imgName, `FROM busybox STOPSIGNAL SIGKILL`, true) c.Assert(err, check.IsNil) - res := inspectFieldJSON(c, name, "Config.StopSignal") + res := inspectFieldJSON(c, imgName, "Config.StopSignal") + if res != `"SIGKILL"` { + c.Fatalf("Signal %s, expected SIGKILL", res) + } + containerName := "test-container-stop-signal" + dockerCmd(c, "run", "-d", "--name", containerName, imgName, "top") + + res = inspectFieldJSON(c, containerName, "Config.StopSignal") if res != `"SIGKILL"` { c.Fatalf("Signal %s, expected SIGKILL", res) } diff --git a/runconfig/opts/parse.go b/runconfig/opts/parse.go index 1c4732c4e5..eb532f654f 100644 --- a/runconfig/opts/parse.go +++ b/runconfig/opts/parse.go @@ -375,7 +375,9 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host Entrypoint: entrypoint, WorkingDir: *flWorkingDir, Labels: ConvertKVStringsToMap(labels), - StopSignal: *flStopSignal, + } + if cmd.IsSet("-stop-signal") { + config.StopSignal = *flStopSignal } hostConfig := &container.HostConfig{