Skip to content
Merged
Show file tree
Hide file tree
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 @@ -31,8 +31,7 @@ This page contains information on how you can set or change the following pre-de
## Methods to override

You can set or change the pre-defined environment variables:
- Within your Compose file using the [`environment` attribute](set-environment-variables.md#use-the-environment-attribute)
- With the `env-file` attribute and an [environment file](set-environment-variables.md#use-the-env_file-attribute)
- With an [`.env` file located in your working director](/manuals/compose/how-tos/environment-variables/variable-interpolation.md)
- From the command line
- From your [shell](variable-interpolation.md#substitute-from-the-shell)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ services:
env_file: "webapp.env"
```

Using an `.env` file lets you to use the same file for use by a plain `docker run --env-file ...` command, or to share the same `.env` file within multiple services without the need to duplicate a long `environment` YAML block.
Using an `.env` file lets you use the same file for use by a plain `docker run --env-file ...` command, or to share the same `.env` file within multiple services without the need to duplicate a long `environment` YAML block.

It can also help you keep your environment variables separate from your main configuration file, providing a more organized and secure way to manage sensitive information, as you do not need to place your `.env` file in the root of your project's directory.

Expand All @@ -85,7 +85,6 @@ The paths to your `.env` file, specified in the `env_file` attribute, are relati
### Additional information

- If multiple files are specified, they are evaluated in order and can override values set in previous files.
- In addition, as the `.env` file supports [interpolation](variable-interpolation.md), it is possible to combine those with values set by `environment`.
- As of Docker Compose version 2.24.0, you can set your `.env` file, defined by the `env_file` attribute, to be optional by using the `required` field. When `required` is set to `false` and the `.env` file is missing, Compose silently ignores the entry.
```yaml
env_file:
Expand Down
Loading