From 6bb0311477b3a995e668a42359228312916dbec0 Mon Sep 17 00:00:00 2001 From: Devendra Kushwah Date: Thu, 18 Jun 2026 20:47:27 +0530 Subject: [PATCH] Clarify dual .env file precedence behavior --- .../how-tos/environment-variables/envvars-precedence.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/content/manuals/compose/how-tos/environment-variables/envvars-precedence.md b/content/manuals/compose/how-tos/environment-variables/envvars-precedence.md index de6b7a558dfd..0b43a481a092 100644 --- a/content/manuals/compose/how-tos/environment-variables/envvars-precedence.md +++ b/content/manuals/compose/how-tos/environment-variables/envvars-precedence.md @@ -21,6 +21,13 @@ The order of precedence (highest to lowest) is as follows: 5. Set in a container image in the [ENV directive](/reference/dockerfile.md#env). 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`. +> [!NOTE] +> +> Compose can load both a local `.env` file and a project-directory `.env` file. +> When both files are present, the local `.env` file takes precedence over the +> project-directory `.env` file. For more information, see +> [local `.env` file versus `.env` file](variable-interpolation.md#local-env-file-versus-project-directory-env-file). + ## Simple example 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: