-
Notifications
You must be signed in to change notification settings - Fork 122
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
docker_container with strict labels comparison ignores base image labels #314
Comments
I'd be happy to submit a PR if this is actually considered a bug. It's surprising behaviour to me, I know I can use |
Hmm, this is somewhat tricky. I think it is a bug, but I'm not sure what the solution should be. The main problem here is that labels present in the image cannot be removed, only overwritten. I can think of two behaviors (when strict comparison is used):
Maybe we need to make this behavior configurable? |
Is there an use case for option |
If you want to make sure that a label isn't there, or if it is there does not have a specific value, having 2. is very useful. If suddenly the image adds a label you don't want to have with a value you don't want to, you find out rather quickly since the module won't create the container. Then you can consider whether you want to mask the label's value by another one you explicitly supply, or (try to) fix the image, or do something else. Just ignoring that there are extra labels could be fatal depending on the label and how the labels are used. |
That makes sense. Since new labels in the image can mess things up I think the default behaviour should be failing when there are labels that can't be removed, if you're OK with adding more configuration we could then add some config like |
The default behavior should be ignore, since failing would be a breaking change (that cannot be merged). I would probably call the option something like |
SUMMARY
When using docker_container to run a container with non-empty
labels
, if its base image also defines labels and labels comparison is set tostrict
the container gets changed.ISSUE TYPE
COMPONENT NAME
docker_container
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
Observed in
archlinux
andUbuntu 21.04
:STEPS TO REPRODUCE
Create a base image with from a Dockerfile which sets labels through the
LABEL
instruction.Run the
docker_container
task twice using this image and the same parameters, with somelabels
set andcomparisons.labels
set tostrict
.There's an example repo here.
Dockerfile:
playbook:
EXPECTED RESULTS
The container should not be changed in the second
docker_container
task:ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: