Description
I'm currently using the env_file feature in compose files to try to automate which dotenv files are automatically used for variable interpolation. The expectation is that if there is a list of env files, the files later in the list override values earlier in the list.
This typically works as expected unless one of the files is .env. Then no matter where it is in that list, those files don't get overridden by the other env files.
Steps To Reproduce
With the following setup:
compose.yml
include:
- path:
- ./compose.include.base.yml
env_file:
- ./.env
- ./.env.local
- ./.env.dev
compose.include.base.yml
services:
env_file_test:
image: env_file_test
build:
args:
TEST_VAL: ${TEST_VAL}
Dockerfile (not technically needed)
FROM debian
ARG TEST_VAL
ENV TEST_VAL=$TEST_VAL
.env
TEST_VAL=".env"
.env.local
TEST_VAL=".env.local"
.env.dev
TEST_VAL=".env.dev"