Skip to content

Extend env_file behavior in the compose file to work like --env-file CLI option #13190

@juergsch

Description

@juergsch

Description

Unfortunately, the two do have similar names but different behavior.

  • This can be confusing.
  • There seems to be no way to define a .env.override file inside the compose file for interpolation to e.g. override a path setting of the volumes section. Of course overriding could be done by the command line. But the composes file seems to be the right place for that.

Example:
The DATA_ROOT_DIR is defined in the .env file. For development, the .env.dev.override should define another location for DATA_ROOT_DIR.

--> In the example below, DATA_ROOT_DIR is taken from .env, not from .env.dev.override

services:
opensearch:
image: opensearchproject/opensearch:latest
container_name: opensearch
env_file:
- path: .env
- path: .env.dev.override
required: false
volumes:
- ${DATA_ROOT_DIR}:/usr/share/opensearch/data # Persist collected data
...

*** Thanks a lot for this great product ***

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions