Skip to content
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

Multiple --env-file? #7847

Closed
leppaott opened this issue Oct 5, 2020 · 12 comments
Closed

Multiple --env-file? #7847

leppaott opened this issue Oct 5, 2020 · 12 comments

Comments

@leppaott
Copy link

leppaott commented Oct 5, 2020

docker-compose --env-file=.env --env-file=.custom_env up -d
Doesn't seem to work but docker-run takes in multiple --env-file? I'd like to merge two env files and now only option seems to be: to include all variables in one env file.

@elovin
Copy link

elovin commented Nov 25, 2020

This would be a very useful feature, because if you have multiple docker-compose files you might want to have some development only env variables to extend/overwrite the env variables for the base docker-compose file.

E.g. I expose some ports in the docker-compose.dev.yml that are used for debugging, I would like to make them configurable through env variables defined in a .dev.env file.

@leppaott
I'm using export $(xargs < .dev.env) before running docker-compose up, take a look at this stackoverflow question.
This can however only extend the environment variables from the --env-file file since it runs before docker-compose, so it can not be used to overwrite environment variables.

@ndeloof
Copy link
Contributor

ndeloof commented Jun 17, 2021

docker run --env-file option doesn't map to docker-compose --env-file but to compose.yaml service.env_file.

That being said, for an homogeneous UX it would indeed make sense to support --env-file as a multi-value flag.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 16, 2022
@stale
Copy link

stale bot commented Apr 27, 2022

This issue has been automatically closed because it had not recent activity during the stale period.

@stale stale bot closed this as completed Apr 27, 2022
@CodeAnthem
Copy link

so is there any progress on this? It would make sense to support multiple .env files. without attaching them to every single service manually.

@ndeloof
Copy link
Contributor

ndeloof commented Feb 16, 2023

@averon420 this is partially supported thanks to compose-spec/compose-go#348
just need to update the flag definition so it can be used N times

@CodeAnthem
Copy link

@averon420 this is partially supported thanks to compose-spec/compose-go#348 just need to update the flag definition so it can be used N times

Sounds awesome, thanks! Sadly, I have no idea what I have to do, to get it to working. Can you give me any hint?

@ndeloof
Copy link
Contributor

ndeloof commented Feb 16, 2023

You can't yet. We need to update the flag definition in compose so you can use it multiple times

@CodeAnthem
Copy link

You can't yet. We need to update the flag definition in compose so you can use it multiple times

Oh I see :) Any idea when this is gonna happen?

@SBD580
Copy link

SBD580 commented May 15, 2023

sounds like a relatively easy one, any intention to add it soon?

@ndeloof
Copy link
Contributor

ndeloof commented May 15, 2023

Multiple use of the --env-file flag is supported since v2.17.0

@ndeloof ndeloof removed the stale label May 15, 2023
@SBD580
Copy link

SBD580 commented May 18, 2023

That's great to hear @ndeloof - thanks (couldn't find a reference in the docs, but maybe I didn't looked hard enough)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants