Declare default environment variables in file
Compose supports declaring default environment variables in an environment file
.env placed in the folder where the
docker-compose command is executed
(current working directory).
These syntax rules apply to the
- Compose expects each line in an
envfile to be in
- Lines beginning with
#are processed as comments and ignored.
- Blank lines are ignored.
- There is no special handling of quotation marks. This means that they are part of the VAL.
Compose file and CLI variables
- Values present in the environment at runtime always override those defined inside the
.envfile. Similarly, values passed via command-line arguments take precedence as well.
- Environment variables defined in the
.envfile are not automatically visible inside containers. To set container-applicable environment variables, follow the guidelines in the topic Environment variables in Compose, which describes how to pass shell environment variables through to containers, define environment variables in Compose files, and more.
More Compose documentation
- User guide
- Installing Compose
- Getting Started
- Command line reference
- Compose file reference
- Sample apps with Compose