-
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
Interpolation of variables in .env ignores shell variables #9045
Comments
Actually the variables are evaluated inside the .env:
docker-compose.yml:
As you can see, the variable |
@ulyssessouza thanks for looking into this. I think if the documentation can be read in different ways, it's worth clarifying.
It doesn't say they aren't, either. This sentence implies they are, at least to me:
So I think the documentation should be updated to avoid ambiguity. But far more interestingly than the documentation itself, I think it would be very useful if the shell-defined variables would have precedence even during Is that something that could be considered? |
This used to work in V1 and leads to breaking changes in our stacks. This is the output using docker-compose V1.26.2:
The way it worked, always respecting the proposed precedence from the documentation is clearly what one is expecting when using it. |
Description
The documentation says that:
This doesn't seem to be the case when interpolating a variable used inside the
.env
file.Steps to reproduce the issue:
Assume a
.env
of:and a
compose.yml
of:Describe the results you received:
I get:
Describe the results you expected:
I expected:
because
VERSION=from_shell
is present in the shell, and should "override [VERSION=from_dot_env
] defined inside the.env
file".Additional information you deem important (e.g. issue happens only occasionally):
I get what I expect if I specify the entire
IMAGE
variable:so it looks like the shell isn't being considered when interpolating variables defined in
.env
.Output of
docker compose version
:I see the same result on V1 and V2.
Output of
docker info
:Additional environment details:
The text was updated successfully, but these errors were encountered: