Skip to content

Make it clear that docker compose shell environment variables must be exported for them to be used by docker compose + other ambiguities #20555

@mushrowan

Description

@mushrowan

Is this a docs issue?

  • My issue is about the documentation content or website

Type of issue

Information is incorrect

Description

In the documentation, it is not made clear that Docker Compose environment variables must be exported for them to take effect. Therefore, for example, simply setting COMPOSE_ENV_FILES=".env1,.env2" in the current shell will not make any Docker Compose commands use the variable, unless the variable was set in /etc/environment.

Furthermore, the documentation claims that:

You can set or change the pre-defined environment variables:

    Within your Compose file using the [environment attribute](https://docs.docker.com/compose/environment-variables/set-environment-variables/#use-the-environment-attribute)
    With the env-file attribute and an [environment file](https://docs.docker.com/compose/environment-variables/set-environment-variables/#use-the-env_file-attribute)"

I believe this to be false with respect to the variables this particular page references. I don't believe there's a way to, for example, set COMPOSE_ENV_FILES from within a compose.yml file - though I'm open to being wrong about this.

Location

https://docs.docker.com/compose/environment-variables/envvars/

Suggestion

Perhaps add a line to make it clear that these variables must be exported.

Furthermore, perhaps on this particular page the lines regarding changing the docker compose variables should be removed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions