-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Official expected behavior about default ENV variables set in images and listed in docker-compose manifest #11962
Comments
That's indeed a bug. |
Hi @ndeloof, Just to be clear you moved this issue from feature to bug, but the new behavior introduced by v2.24.7 is good for me. |
This behavior is inconsistent with |
Is there a chance to consider it as an unintentional improvement ? 😆 What do you mean exactly about the inconsistency with
) But in a docker-compose manifest, this is different because if it contains:
The utility of doing that is not necessarily to unset the TEST variable, but just passing its value to the container if the TEST variable is set in .env, any other Even since v2.24.7 if you want to unset the variable you can do this explicitly with:
I'm little disappointed if the new behavior is removed, because it makes the definition of default values inside images more complicated (for example to define default values in images, to be used both by docker-compose and k8s). If the new behavior is considered as a regression and reverted, would it be possible to have a new mark ? for example:
and/or:
To be able to define a variable to be passed to the container, but not unset it if not defined (and/or if |
I think this is the same as #11740 (or similar issue with unsetting variables and precedence order) |
could be an option, but would be better the same behavior is available with the docker CLI for consistency. |
Description
I found an important difference in docker-compose behavior regarding default variables set in images, since v2.24.7.
Knowing that we have an image containing a variable "VAR" with a default value "default", the Dockerfile specifies:
ENV VAR "default"
If the environment section of the docker-compose manifest specifies a variable "VAR" (without value):
Regardless of the version, if the environment section of the docker-compose manifest specifies "VAR=" (with the equal sign and no value), the variable is set as empty in the container.
This difference in behavior is important because:
For me the behavior since v2.24.7 is the good one, but it doesn't appear in changelog, I don't even not know which issue or commit changed this, it's maybe just a side effect.
Can you confirm this behavior introduced by v2.24.7 is the expected one and can you add it to the official documentation ?
If a unit test could ensure this behavior will not be lost it would be great.
The text was updated successfully, but these errors were encountered: