Skip to content

Commit 6bb0311

Browse files
Clarify dual .env file precedence behavior
1 parent b3d65d3 commit 6bb0311

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

content/manuals/compose/how-tos/environment-variables/envvars-precedence.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ The order of precedence (highest to lowest) is as follows:
2121
5. Set in a container image in the [ENV directive](/reference/dockerfile.md#env).
2222
Having any `ARG` or `ENV` setting in a `Dockerfile` evaluates only if there is no Docker Compose entry for `environment`, `env_file` or `run --env`.
2323

24+
> [!NOTE]
25+
>
26+
> Compose can load both a local `.env` file and a project-directory `.env` file.
27+
> When both files are present, the local `.env` file takes precedence over the
28+
> project-directory `.env` file. For more information, see
29+
> [local `.env` file versus <project directory> `.env` file](variable-interpolation.md#local-env-file-versus-project-directory-env-file).
30+
2431
## Simple example
2532

2633
In the following example, a different value for the same environment variable in an `.env` file and with the `environment` attribute in the Compose file:

0 commit comments

Comments
 (0)