Skip to content

Is it possible to set environment variables in a file? #2492

Answered by itzg
nmills3 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes it is. With a compose project, a .env file is automatically included if present or can be explicitly referenced:

https://docs.docker.com/compose/environment-variables/set-environment-variables/#substitute-with-an-env-file

With docker run you can reference env files with --env-file:

https://docs.docker.com/engine/reference/commandline/run/#env

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nmills3
Comment options

Answer selected by nmills3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants