mirror of
https://github.com/docker/compose.git
synced 2025-07-24 22:24:41 +02:00
Fix .env and --envfile priorities
Signed-off-by: Ulysses Souza <ulyssessouza@gmail.com>
This commit is contained in:
parent
def189fae1
commit
bac398aa9f
@ -78,6 +78,19 @@ func TestEnvPriority(t *testing.T) {
|
|||||||
assert.Equal(t, strings.TrimSpace(res.Stdout()), "shell-run")
|
assert.Equal(t, strings.TrimSpace(res.Stdout()), "shell-run")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// No Compose file & no env variable but override env file
|
||||||
|
// 1. Compose file
|
||||||
|
// 2. Shell environment variables
|
||||||
|
// 3. Environment file <-- Result expected
|
||||||
|
// 4. Dockerfile
|
||||||
|
// 5. Variable is not defined
|
||||||
|
t.Run("override env file from compose", func(t *testing.T) {
|
||||||
|
res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose-with-env-file.yaml",
|
||||||
|
"--project-directory", projectDir,
|
||||||
|
"run", "--rm", "-e", "WHEREAMI", "env-compose-priority")
|
||||||
|
assert.Equal(t, strings.TrimSpace(res.Stdout()), "override")
|
||||||
|
})
|
||||||
|
|
||||||
// No Compose file & no env variable but override env file
|
// No Compose file & no env variable but override env file
|
||||||
// 1. Compose file
|
// 1. Compose file
|
||||||
// 2. Shell environment variables
|
// 2. Shell environment variables
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
env-compose-priority:
|
||||||
|
image: env-compose-priority
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
env_file:
|
||||||
|
- .env.override
|
Loading…
x
Reference in New Issue
Block a user