Skip to content

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

Closed

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)

Activity

  1. dnephin commented on Mar 22, 2016

    @dnephin

    This is working as intended. Environment variables with values should not be overridden from the host values.

    There is no way to achieve that yet. There will be in 1.7.0 using an docker-compose.env file, and later there may be a way to specify default-if-not-set values in the Compose file itself (#3108).

  2. aleemb commented on Mar 22, 2016

    @aleemb
    Author

    Tripped me up since args are allowed overrides. There are a other issues open for variable interpolation so I suppose that may allow a workaround as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to 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