env_file usage
Get environment variables from a file, which can be a separate file path or a list.
If docker-compose -f FILE
the Compose template file is specified via the method, the path to the variable in env_file will be based on the template file path.
If a variable name environment
conflicts with a directive, by convention the latter takes precedence.
env_file: .env
env_file:
- ./common.env
- ./apps/web.env
- /opt/secrets.env
Each line in the environment variable file must conform to the format, and comment lines starting with # are supported.
# common.env: Set development environment
PROG_ENV=development
.env will be read automatically
The scope of environment and env_file
There is a difference in the scope of environment and env_file. From the perspective of environment variables, environment has a higher priority. From the perspective of placeholder replacement, only env_file(.env) can be used.
links: