Closed bastiane273 closed 2 months ago
env_file
is used to set container environment (same as docker run --env-file
), not for interpolation. See https://docs.docker.com/compose/environment-variables/variable-interpolation/
There is no interpolation I do use only more than one .env file - e.g. .env and glogal.env and .env will be treated in an other way than global.env: If I am using env_file in combination with environment - there are surprising result: e.g. .env
Var1=1
global.env
Var1=2
Result=> 1 What about the other way round docker-compose.yml
env_file:
- global.env:
- .env
In my opinion .env should win :-)
OK
env_file:
- .env
- global.env
In my opinion gobal.env should win . It doesn't Let's make a little more difficult: I want that same variable are given to the container and some not: e.g.:
env_file:
- .env
- global.env
environment:
VARa_from_env: (works)
VABb_from_global.env: (don't works - why)
I didn't try any combination, but it seems to be, that .env is more "worth" than global.env - without any order. Is this an intended behavior?
Greetings Bastian
This line traefik.http.routers.paperless.rule: "Host(
${PAPERLESS_HOSTNAME}.${GLOBAL_DOMAIN})"
will trigger variable interpolation if you don't double the $
sign (assuming this is Traeffic role to manage such variables)
The reason you get variables set from .env
is not that you selected the right order in env_file
, but .env
is the default location for interpolation. env_file
is not used for interpolation, but to define container's environment
Is there an possibility to include an other env-file in .env?
no. But you can repeat --env-file
flag to load multiple env files
Description
If I am using more than one env_file - it does not seem to work
Steps To Reproduce
.env:
global.env
docker-compose.yml
an docker compose config will show traefik.http.routers.paperless.rule: "Host(
paperless.
})"this
.
})"this (no env_file defined, but env-file is existing will result in traefik.http.routers.paperless.rule: "Host(
paperless.
})"Compose Version
Docker Environment
Anything else?
In my opinion such a behavior makes no sense :-)
Thanks for your great software.