-
Notifications
You must be signed in to change notification settings - Fork 130
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
Behavior of docker_container around images differs from documented #421
Comments
Did you run the playbook/task with What I can imagine goes wrong in your case is that the expected container configuration is computed based on the image (https://github.com/ansible-collections/community.docker/blob/main/plugins/modules/docker_container.py#L2230-L2245), and here not the image used by the container is used, but the image specified to the module. So depending on how the two images (the one used by the container, and the one mention in the module's configuration) differ, this could cause recreation of the container. |
TIL, I didn't know about
|
The expected environment is computed from the image's environment and the module's I think the correct way to handle this would be to use the correct image to compute the differences: if the image is ignored, use the image currently used for the contained in this comparison. Unfortunately the old behavior has been in use for quite a few years now, and I'm not sure whether backporting a change for this is a good idea, since this might cause some breakage with existing playbooks / tasks which expect this behavior. In any case, you can work around this by specifying |
Ignoring env would make it ignore all environment variables which is usually undesirable. Either way all my use-cases are covered by
which is not correct because the image is not checked against the registry unless pull is set to true |
#428 adds an option which allows to control this behavior. |
SUMMARY
The documentation states:
The actual behavior of docker_container module is that neither
comparison -> image: ignore
norignore_image: true
make any effect.ISSUE TYPE
COMPONENT NAME
docker_container
ANSIBLE VERSION
COLLECTION VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
by default (as described in the documentation) docker_container pulls remote image if changed (this may require changing the default for
pull
to true)ignore_image
andimage: ignore
are either respected or removed (according to the documentation the expected behavior of ignore matches to whatpull: true/false
does, therefore these parameters seem to be useless unless they allow ignoring changes to local image if anybody every needs this)ACTUAL RESULTS
To illustrate I'll describe a few cases below.
Case 1 (default module settings)
before running
after running
Case 2 (pull is set to true)
before running
after running
Note: neither
ignore_image: true
norcomparison -> image: ignore
change the behavior described aboveThe text was updated successfully, but these errors were encountered: