-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Feature Request: option to disable reading from .env #4642
Comments
Compose doesn't insert the values from |
So, from the docs, Compose will only use The way the docs are laid out didn't make it clear to me. When I am reading the docs and get to the Before understanding this, I was getting different results when I executed my container using Thanks for the the answer. Closing. |
For any future googlers finding this issue because they wanted foreman to stop loading their env files: The way I found is |
I am using Docker Compose to run a Rails application that has a component to read from the
.env
file as well (Dotenv: https://github.com/bkeepers/dotenv).After trying to figure out why my environment variables were getting all messed up whenever I ran the app using Compose, I found out about Compose's ability to automatically read from
.env
, and realized it was affecting Dotenv's workflow, which ignores variables set by system.Example:
VAR=0
(default value)VAR=1
Expected behavior: VAR == 1
Upon launching the app in development, Dotenv will read from
.env.development
first and setVAR
to 1 (because a system variable is not expected to be set). When it falls back to.env
, VAR is already set so it won't be touched. This is how Dotenv's workflow works.Received behavior: VAR == 0
Compose will have read from
.env
and setVAR
to 0 in the system/container before launching the app. So when Dotenv reads.env.development
, it will skipVAR
because value will already be set by system.I could set the development value directly in
.env
, but then, the same thing would happen in.env.test
or any other local environment.I don't generally use
.env
for Compose, so I'd like an option to disable this specific magic. Or just remove it, since I can already achieve the exact same thing usingenv_file
, if I need it.Thanks.
The text was updated successfully, but these errors were encountered: