Closed Adrien-Atmosphere closed 11 months ago
While this indeed sounds like a regression we have to fix, you better should use --env-file instance1/.env
to select the env file with required configuration, vs getting into a subfolder to run commands
The reason you get this behavior is due to project directory definition
As you run command from instance1
folder, Docker Compose will search for a compose.yaml
file, and then look into parent folder. This discovery also defines project directory as parent folder, and this is where a default .env
file is also searched for (not in you command line working directory). This used to be the case in some earlier releases but this come with many other issues and weird behaviors.
I'm closing this issue as "work as expected". As suggested, you can rely on --env-file
to select an alternate env file to get profiles enabled
Description
I have a single compose file that defines multiple profiles. I have multiple sub-directories that contains .env file where the environment variable COMPOSE_PROFILES is defined. To start different profile configuration, I would basically go to the appropriate folder and launch
docker compose up -d
. Using docker compose version v2.20.2, the profiles defined in the .env file were properly used. But it is not working anymore in v2.21.0.Could you please advise if my use case was an unintended behavior from the old versions?
Steps To Reproduce
compose.yml :
instance1/.env :
Go to instance1 folder and
docker compose up -d
with docker compose version v2.20.2Do the same thing using docker compose version v2.21.0 :
Compose Version
Docker Environment
Anything else?
No response