Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 <project directory> `.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:
Expand Down