Browse code

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 <david.calavera@gmail.com>

David Calavera authored on 2016/02/13 07:56:40
Showing 3 changed files
... ...
@@ -89,6 +89,10 @@ func merge(userConf, imageConf *containertypes.Config) error {
89 89
 			userConf.Volumes[k] = v
90 90
 		}
91 91
 	}
92
+
93
+	if userConf.StopSignal == "" {
94
+		userConf.StopSignal = imageConf.StopSignal
95
+	}
92 96
 	return nil
93 97
 }
94 98
 
... ...
@@ -5777,14 +5777,21 @@ func (s *DockerSuite) TestBuildNullStringInAddCopyVolume(c *check.C) {
5777 5777
 
5778 5778
 func (s *DockerSuite) TestBuildStopSignal(c *check.C) {
5779 5779
 	testRequires(c, DaemonIsLinux)
5780
-	name := "test_build_stop_signal"
5781
-	_, err := buildImage(name,
5780
+	imgName := "test_build_stop_signal"
5781
+	_, err := buildImage(imgName,
5782 5782
 		`FROM busybox
5783 5783
 		 STOPSIGNAL SIGKILL`,
5784 5784
 		true)
5785 5785
 	c.Assert(err, check.IsNil)
5786
-	res := inspectFieldJSON(c, name, "Config.StopSignal")
5786
+	res := inspectFieldJSON(c, imgName, "Config.StopSignal")
5787
+	if res != `"SIGKILL"` {
5788
+		c.Fatalf("Signal %s, expected SIGKILL", res)
5789
+	}
5790
+
5791
+	containerName := "test-container-stop-signal"
5792
+	dockerCmd(c, "run", "-d", "--name", containerName, imgName, "top")
5787 5793
 
5794
+	res = inspectFieldJSON(c, containerName, "Config.StopSignal")
5788 5795
 	if res != `"SIGKILL"` {
5789 5796
 		c.Fatalf("Signal %s, expected SIGKILL", res)
5790 5797
 	}
... ...
@@ -375,7 +375,9 @@ func Parse(cmd *flag.FlagSet, args []string) (*container.Config, *container.Host
375 375
 		Entrypoint:      entrypoint,
376 376
 		WorkingDir:      *flWorkingDir,
377 377
 		Labels:          ConvertKVStringsToMap(labels),
378
-		StopSignal:      *flStopSignal,
378
+	}
379
+	if cmd.IsSet("-stop-signal") {
380
+		config.StopSignal = *flStopSignal
379 381
 	}
380 382
 
381 383
 	hostConfig := &container.HostConfig{