Browse code

Revert "Container don't inherit from image labels"

This reverts commit 79621c7728ab83292ffd94d005f10ccebfba055b.

Signed-off-by: Darren Shepherd <darren@rancher.com>

Darren Shepherd authored on 2015/08/12 08:48:41
Showing 2 changed files
... ...
@@ -229,7 +229,7 @@ func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) {
229 229
 	}
230 230
 
231 231
 	name := "test_create_labels_from_image"
232
-	expected := map[string]string{"k2": "x", "k3": "v3"}
232
+	expected := map[string]string{"k2": "x", "k3": "v3", "k1": "v1"}
233 233
 	dockerCmd(c, "create", "--name", name, "-l", "k2=x", "--label", "k3=v3", imageName)
234 234
 
235 235
 	actual := make(map[string]string)
... ...
@@ -47,6 +47,16 @@ func Merge(userConf, imageConf *Config) error {
47 47
 		}
48 48
 	}
49 49
 
50
+	if userConf.Labels == nil {
51
+		userConf.Labels = map[string]string{}
52
+	}
53
+	if imageConf.Labels != nil {
54
+		for l := range userConf.Labels {
55
+			imageConf.Labels[l] = userConf.Labels[l]
56
+		}
57
+		userConf.Labels = imageConf.Labels
58
+	}
59
+
50 60
 	if userConf.Entrypoint.Len() == 0 {
51 61
 		if userConf.Cmd.Len() == 0 {
52 62
 			userConf.Cmd = imageConf.Cmd