Browse code

Container don't inherit from image labels

Labels are metadata that apply to a particular resource: image,
container, maybe volumes and networks in the future. We shouldn't have
containers inherit from its image labels: they are not the same obejcts,
and labels cannot be interpreted in the way.

It remains possible to apply metadata to an image using the LABEL
Dockerfile instruction, to query them using `docker inspect <img>`, or
to filter images on them using `docker images --filter <key>=<value>`.

Fixes #13770.

Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>

Arnaud Porterie authored on 2015/06/06 02:56:25
Showing 2 changed files
... ...
@@ -269,7 +269,7 @@ func (s *DockerSuite) TestCreateLabelFromImage(c *check.C) {
269 269
 	}
270 270
 
271 271
 	name := "test_create_labels_from_image"
272
-	expected := map[string]string{"k2": "x", "k3": "v3", "k1": "v1"}
272
+	expected := map[string]string{"k2": "x", "k3": "v3"}
273 273
 	if out, _, err := runCommandWithOutput(exec.Command(dockerBinary, "create", "--name", name, "-l", "k2=x", "--label", "k3=v3", imageName)); err != nil {
274 274
 		c.Fatal(out, err)
275 275
 	}
... ...
@@ -41,16 +41,6 @@ func Merge(userConf, imageConf *Config) error {
41 41
 		}
42 42
 	}
43 43
 
44
-	if userConf.Labels == nil {
45
-		userConf.Labels = map[string]string{}
46
-	}
47
-	if imageConf.Labels != nil {
48
-		for l := range userConf.Labels {
49
-			imageConf.Labels[l] = userConf.Labels[l]
50
-		}
51
-		userConf.Labels = imageConf.Labels
52
-	}
53
-
54 44
 	if userConf.Entrypoint.Len() == 0 {
55 45
 		if userConf.Cmd.Len() == 0 {
56 46
 			userConf.Cmd = imageConf.Cmd