Skip to content

Env variable override not possible from host if default value present #3183

@aleemb

Description

@aleemb
  1. As expected:

    environment:
    - FOO
    
    FOO=external docker-compose run test env
    # shows "external"
    
  2. As expected:

    environment:
    - FOO=internal
    
    docker-compose run test env
    # shows "internal"
    
  3. Weirdness:

    environment:
    - FOO=internal
    
    FOO=external docker-compose run test env
    # shows "internal"
    

The output should be external since the host overrode the default value.

Is there any way right now (1.6.2) to achieve 3? That is, to allow for an environment variable from host but fallback to a default value if absent?

Also referenced by @fazy in #1377 (comment)

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