-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENDOCS-2003 #19541
ENDOCS-2003 #19541
Conversation
✅ Deploy Preview for docsdocker ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
- The various ways you can [set environment variables with Compose](set-environment-variables.md). | ||
- [How environment variable precedence works](envvars-precedence.md). | ||
- The correct syntax for an [environment file](env-file.md). | ||
This section covers key content such as: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have tried to make the distinction clear here that we're talking about 2 use cases for environment variables
@@ -7,79 +7,97 @@ aliases: | |||
- /compose/envvars-precedence/ | |||
--- | |||
|
|||
When the same environment variable is set in multiple sources, Docker Compose follows a precedence rule to determine the value for that variable. | |||
When the same environment variable is set in multiple sources, Docker Compose follows a precedence rule to determine the value for that variable in your container's environment. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have made it clearer that we're talking about precedence for the container's environment
@@ -256,8 +230,5 @@ $ docker compose run -e DEBUG=1 web python console.py | |||
|
|||
The value of the `DEBUG` variable in the container is taken from the value for the same variable in the shell in which Compose is run. | |||
|
|||
## Further resources |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Up above on line 216 Set environment variables with
docker compose run --env` - if that is a method to set variables in the container's environment, shouldn't that be on this page https://deploy-preview-19541--docsdocker.netlify.app/compose/environment-variables/set-container-environment-variables/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Set environment variables with docker compose run --env" applies to container's environment, not compose variables, should be moved to set-container-environment-variables
page
environment: | ||
DEBUG: "true" | ||
``` | ||
|
||
#### Additional information |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section should be moved to set-container-environment-variables page, as this isn't related to variables in compose.yaml ("interpolation") but container's environement
|
||
### Additional information | ||
- If multiple files are specified, they are evaluated in order and can override values set in previous files. | ||
- Environment variables declared in the `.env` file cannot then be referenced again separately in the Compose file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what this is about, this sentence doesn't make sense to me
- Environment variables declared in the `.env` file cannot then be referenced again separately in the Compose file. | ||
- If you use both the `env_file` and `environment` attribute, environment variables set by `environment` take precedence. | ||
- The paths to your `.env` file, specified in the `env_file` attribute, are relative to the location of your `compose.yml` file. | ||
- Values in your `.env` files can be overridden from the command line by using [`docker compose run -e`](set-variables.md#set-environment-variables-with-docker-compose-run---env). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is actually wrong, as run -e set container environment, not compose.yaml variables
- The paths to your `.env` file, specified in the `env_file` attribute, are relative to the location of your `compose.yml` file. | ||
- Values in your `.env` files can be overridden from the command line by using [`docker compose run -e`](set-variables.md#set-environment-variables-with-docker-compose-run---env). | ||
- Your `.env` files can be overriden by another `.env` if it is [substituted with `--env-file`](set-variables.md#substitute-with---env-file). | ||
- As of Docker Compose version 2.24.0, you can set your `.env` file to be optional by using the `required` field. When `required` is set to `false` and the `.env` file is missing, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can set file defined by env_file
to be optional, .env
is unrelated here
- If you use both the `env_file` and `environment` attribute, environment variables set by `environment` take precedence. | ||
- The paths to your `.env` file, specified in the `env_file` attribute, are relative to the location of your `compose.yml` file. | ||
- Values in your `.env` files can be overridden from the command line by using [`docker compose run -e`](set-variables.md#set-environment-variables-with-docker-compose-run---env). | ||
- Your `.env` files can be overriden by another `.env` if it is [substituted with `--env-file`](set-variables.md#substitute-with---env-file). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.env
is a file name, so there can't be "another .env
?
I'm not sure I understand what this recommendation is about
@aevesdocker can we move forward with this one ? |
Yes @ndeloof, I promise I haven't forgotten about this. Will get to this ASAP |
Description
Builds on #19481
Related issues or tickets
Reviews