mirror of https://github.com/docker/docs.git
parent
d282ce0a63
commit
2ab284be75
|
|
@ -5,15 +5,15 @@ keywords: compose, environment, env file
|
|||
---
|
||||
|
||||
## Order of precedence
|
||||
1. Passed from the command-line [`docker compose run --env <KEY[=VAL]>`](../../engine/reference/commandline/compose_run/#options).
|
||||
2. Passed from/set in `compose.yaml` service's configuration, [from the environment key](../../compose/compose-file/#environment).
|
||||
3. Passed from/set in `compose.yaml` service's configuration, [from the env_file key](../../compose/compose-file/#env_file).
|
||||
4. Passed from/set in Container Image [in ENV directive](../../engine/reference/builder/#env).
|
||||
1. Passed from the command-line [`docker compose run --env <KEY[=[VAL]]>`](../../engine/reference/commandline/compose_run/#options).
|
||||
2. Passed from/set in `compose.yaml` service's configuration, from the [environment key](../../compose/compose-file/#environment).
|
||||
3. Passed from/set in `compose.yaml` service's configuration, from the [env_file key](../../compose/compose-file/#env_file).
|
||||
4. Passed from/set in Container Image in [ENV directive](../../engine/reference/builder/#env).
|
||||
|
||||
### Precedence quick overview table
|
||||
The table below provides a quick overview of how interpolation works when using all environment variables on Compose, using `TAG`, an environmental variable defining the version for an image, as an example.
|
||||
|
||||
Each row represents a scenario and each columns represents a context where you can be setting or passing an environment variable.
|
||||
Each row represents a scenario and each column represents a context where you can be setting or passing an environment variable.
|
||||
|
||||
| # | `.env` file | `compose.yaml`:`env_file` key | `compose.yaml`:`environment` key | CMD | Image | OS | Resolved as |
|
||||
|:-:|:--------------------------:|:-----------------------------:|:---------------------------------:|:------------:|:-------------:|:------------:|:-----------------:|
|
||||
|
|
@ -35,8 +35,12 @@ Each row represents a scenario and each columns represents a context where you c
|
|||
| 16| Unset | Unset | `TAG=1.7` | Unset | `TAG=1.6` | `TAG=1.4` | `TAG=1.4` |
|
||||
|
||||
Description for each column:
|
||||
* `.env` file - `.env` file on the project root (or, with higher precedence, the file passed via `docker compose -–env-file <FILE>`).
|
||||
* `OS` environment - OS Environment variable
|
||||
* Image - `ENV` directive in the Dockerfile
|
||||
* .env file - `.env` file on the project root (or, with higher precedence, the file passed via `docker compose -–env-file <FILE>`).
|
||||
* Command line - environmental variable passed via `docker compose run -e <KEY[=VAL]>`.
|
||||
* Compose file - in `environment` key from the service section in the `compose.yaml`.
|
||||
* Compose file - in `env_file key` from the service section in the `compose.yaml`.
|
||||
* Compose file - In `env_file` key from the service section in the `compose.yaml`.
|
||||
* Compose file - In `environment` key from the service section in the `compose.yaml`.
|
||||
* Command line - Environmental variable passed via `docker compose run -e <KEY[=[VAL]]>`.
|
||||
* Resolved as - This column expresses the result available in the container.
|
||||
|
||||
**Note that the "`OS`" has precedence over "`.env` file" column for variable resolution in the other columns.**
|
||||
Loading…
Reference in New Issue