-
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
[BUG] Incompatible .env
file behavior
#11880
Comments
This indeed is feature introduced by #11861, which existed (while undocumented) in earlier releases - documentation update will come soon, the whole environment section is being rewritten I tried to reproduce, but works as expected:
so I get the $PWD/.env to override values set by /.env |
ok, got it. The issue is about |
Re-tested and that indeed seems to be the case. All variables are loaded correctly from both files, with I even added variables into the config for debugging: ...
environment:
- COMPOSE_PROFILES=${COMPOSE_PROFILES} and |
This issue might be actually a duplicate of #11856, which already has a fix. |
I might have a similar (same?) issue but with A downgrade to version 2.27.0 works like before, so I think this may be the same issue, maybe all |
Description
Before
2.27.1
,.env
file was automatically loaded from the project directory. However in2.27.1
, the.env
file is loaded only from the working directory and the project directory's.env
file is ignore regardless whether there's.env
in the working directory.This affects both
--project-directory
and--file
options and it seems that--env-file
is also ignored.Steps To Reproduce
Behavior can be easily verified using
docker compose config
command, but affect other commands such asdocker compose up
.Let's assume scenario with following project structure:
# file: sub/.env COMPOSE_PROFILES=sub
2.27.0
and prior at least down to2.24.5
All 3 of the commands below resulted in the same output and all these commands correctly load the
sub
profile.docker compose --project-directory sub config docker compose --file sub/docker-compose.yaml config (cd sub && docker compose config)
2.27.1
When
docker compose
specified either--project-directory sub
or--file sub/docker-compose.yaml
, the./.env
file was loaded instead of./sub/.env
.So as expected, command that uses
cd
still behaves the same way.(cd sub && docker compose config)
However 2 of the commands below resulted in the different output compared to prior versions as no
.env
profile is loaded andCOMPOSE_PROFILES
is not set.This then results in behavior such as getting
no service selected
when usingdocker compose --project-directory <dir> up
. Command which used to work in past suddenly stopped working.What makes it even worse is that
--env-file
should have a priority over implicit default, it seems to be ignored regardless of file's location.Compose Version
Docker Environment
Anything else?
At first glance, this seems to be a result of allow a local .env file to override compose.yaml sibling .env PR.
Note that
<project_directory>/.env
doesn't have lower priority than$PWD/.env
(as that one doesn't exist), but it's entirely ignored instead.The text was updated successfully, but these errors were encountered: