Skip to content
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

Closed
wants to merge 4 commits into from
Closed

ENDOCS-2003 #19541

wants to merge 4 commits into from

Conversation

aevesdocker
Copy link
Contributor

Description

Builds on #19481

Related issues or tickets

Reviews

  • Technical review
  • Editorial review
  • Product review

@github-actions github-actions bot added the area/compose Relates to docker-compose.yml spec or docker-compose binary label Feb 29, 2024
Copy link

netlify bot commented Feb 29, 2024

Deploy Preview for docsdocker ready!

Name Link
🔨 Latest commit 40b8871
🔍 Latest deploy log https://app.netlify.com/sites/docsdocker/deploys/65e70578195b070007aa529c
😎 Deploy Preview https://deploy-preview-19541--docsdocker.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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:
Copy link
Contributor Author

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.
Copy link
Contributor Author

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
Copy link
Contributor Author

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/

Copy link
Contributor

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
Copy link
Contributor

@ndeloof ndeloof Mar 26, 2024

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.
Copy link
Contributor

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).
Copy link
Contributor

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,
Copy link
Contributor

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).
Copy link
Contributor

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

@ndeloof
Copy link
Contributor

ndeloof commented May 21, 2024

@aevesdocker can we move forward with this one ?

@aevesdocker
Copy link
Contributor Author

Yes @ndeloof, I promise I haven't forgotten about this. Will get to this ASAP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/compose Relates to docker-compose.yml spec or docker-compose binary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants