-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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 variable precedence in V2 - was working in V1 #9442
Interpolation of variables in .env ignores variable precedence in V2 - was working in V1 #9442
Comments
fixed by #9475 |
@ndeloof - Based on my experience, #9475 introduced a regression in Output of Docker Compose version v2.5.1 test.env IMAGE=from_env compose-config.yaml services:
echo:
image: bash
environment:
- IMAGE
command: echo "$IMAGE" Result without shell override $ docker-compose -f compose-config.yaml --env-file test.env config
name: test
services:
echo:
command:
- echo
- from_env
environment:
IMAGE: from_env
image: bash
networks:
default: null
networks:
default:
name: test_default Result with shell override $ IMAGE=from_shell docker-compose -f compose-config.yaml --env-file test.env config
name: test
services:
echo:
command:
- echo
- from_env
environment:
IMAGE: from_env
image: bash
networks:
default: null
networks:
default:
name: test_default The above test correctly showed The new behavior in
|
+1 Currently .env overrides everything provided in shell, which is the opposite of what the documentation says. EDIT: using compose v1 instead of v2 cirumvents the problem |
@tboddyspargo indeed, my fix is incomplete, sorry for this |
Hi @ndeloof FYI I built from the latest master to try to get past this bug and I am seeing that the variables in an .env file still override any variable provided through the shell. The go.mod file has compose-go 1.2.6. ❯ docker-compose version |
works now 💯 👍 thank you |
Description
The documentation is stating:
Interpolation in .env recently broke with that behaviour and is ignoring precendence of variables in the shell. The behaviour was introduced in V2 and was working in V1 leading to an unnecessary breaking change.
Reference: 9045
Steps to reproduce the issue:
Assume a .env of:
and a compose.yml of:
Describe the results you received:
in V2 (using --compatibility does not make any difference):
in V1:
Describe the results you expected:
I expect V2 to also return the same consistent output regarding environment variable precedence as V1 is producing:
Additional information you deem important (e.g. issue happens only occasionally):
Output of
docker compose version
:Output of
docker info
:Additional environment details:
The text was updated successfully, but these errors were encountered: