-
Notifications
You must be signed in to change notification settings - Fork 18.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Container don't inherit from image labels #13772
Container don't inherit from image labels #13772
Conversation
e940736
to
8e0de9d
Compare
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 moby#13770. Signed-off-by: Arnaud Porterie <arnaud.porterie@docker.com>
8e0de9d
to
79621c7
Compare
LGTM |
1 similar comment
LGTM |
Container don't inherit from image labels
Thanks @icecrime, in hindsight, I should've been more persistent asking about the desired behavior #9882 (comment). Guess the discussion just got too long and I forgot. 😊 |
ping @icecrime @jfrazelle @duglin and @vieux (for API) Gave this some more thought, and apologies upfront for being a PITA. If I understand correctly, this will be a backwards incompatible change and, although I haven't checked if this behavior is actually documented, users will be relying on the current behavior, so we need something to address that. (Envisioning a range of bugs reported by @ibuildthecloud once this change lands in a release);
If any of these points are incorrect or don't make sense, please comment, just want to make sure we don't break existing setups. |
Oh this is a terrible change, why???? This breaks me. I use container labels extensively to indicate attributes about the container. By having the labels come from the image I can have images automatically contribute attributes to the container. For example, I can tell a user to add the label "make-awesome" and in Rancher it will do something cool with that container. But the user is free to put the label on the image and now all of their containers will be made awesome automatically. This change breaks that behavior. If you want to separate the two then we can add something like CONTAINER_LABEL in the dockerfile, but I honestly don't see a lot of value beyond the theoretical. But please revert this PR until we have a sufficient solution. |
Also, this wasn't an oversight on my part, the behavior was quite intentional, but maybe we didn't discuss this enough. |
@rhatdan do you have any thoughts on this one? |
I also take it for granted that they layers get inherited unless overwritten. I don't believe their is a good solution to this. I believe the president has been set of other fields in layers. We are telling our vendors who are building content on our images to modify some of the LABELS, that end up being clearly wrong. Vendor, Name, Version, Release for example. But I do not believe that if i examine a container that is based on rhel7 should n ot show that fact in docker inspect. So I would vote to veto this change. |
@ibuildthecloud couldn't you achieve exactly the same thing with a It seems weird to me that the author of an image can have such a direct influence on host-specific behavior. I can see security risks caused by conflating image and container lables, too. For example, let's assume a certain number of Docker deployments are configured to pick up the container label |
I support @icecrime here, I think it's better to keep container labels and image labels clearly separate, to keep a sane and intuitive data model. However I don't see any reason why a user couldn't query containers by various properties of the image which it came from - including image labels. But at least it would be a conscious decision by the user to tie behavior on their installation to potentially untrusted or broken image properties. |
I agree container labels and image labels should probably be different. |
Also, I'd like to point out that it should be simple enough to do the "extra indirection" of grabbing the image name from a running container and inspect its labels. |
@ibuildthecloud @icecrime @shykes wrt breaking backward compatibility and API stability (it is versioned for a reason), I think my comment #13772 (comment) still contains some things that need to be addressed |
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 objects, 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 usingdocker images --filter <key>=<value>
.Fixes #13770.
Signed-off-by: Arnaud Porterie arnaud.porterie@docker.com