Skip to content

env_file doesn't get extended #2446

Closed
Closed

Description

@krasi-georgiev

https://github.com/vipconsult/dockerfiles

docker-compose -f always-on-prod.yml --x-networking up -d

this extends always-on.yml which on it side extends common.yml which has
env_file:
- env

always-on-prod.yml defines its own env_file
env_file:
- env-prod

the problem is that envs defined in the env-prod don't override the envs defined in common.yml

I think this worked as expected before I upgraded from 1.5.0

Docker version 1.9.0, build 76d6bc9
docker-compose version: 1.6.0dev

linux debian jessie

Activity

  1. dnephin commented on Nov 23, 2015

    @dnephin

    I've created this gist: https://gist.github.com/dnephin/447b293cfca7099822d0

    It has a minimal example of a service (top) which extends another (common), both of which use env_file and environment. There are four env variables, and I'd expect one to be set from each source.

    The gist includes output from different compose versions, starting at 1.4.2.

    In 1.4.2 and 1.5.0 the output is consistent, but TEST_TWO comes from the top env_file. I would have expected it to come from common, because environment always overrides env_file.

    In 1.5.1 (and in #2418) the output is consistent. TEST_TWO is now set by common (which is a change, but what I would expect), but TEST_TREE (just noticing the typo now) is set by common env_file. I would expect it to be set by top env-file. I believe this issue is about this case.

    We need to also make sure that the change in behaviour from 1.5.0 to 1.5.1 is expected and matches our documentation.

  2. dnephin commented on Nov 23, 2015

    @dnephin

    I've got a branch (master...dnephin:fix_env_file_ordering) which fixes this to do what I would expect. It's based off the work in #2405

    top_1 | TEST_FOUR=common-env-file
    top_1 | TEST_ONE=top
    top_1 | TEST_TREE=top-env-file
    top_1 | TEST_TWO=common
    

    @aanand, @shin- does the above sound right?

  3. added this to the 1.5.2 milestone on Nov 23, 2015
  4. krasi-georgiev commented on Nov 23, 2015

    @krasi-georgiev
    Author

    now the ordering for the env_file is fine , haven't tested the environment one

    another problem
    docker-compose --x-networking up -d top - doesn't recreate the container if you make changes in top.env

  5. dnephin commented on Nov 23, 2015

    @dnephin

    now the ordering for the env_file is fine

    You mean with the branch I linked?

    doesn't recreate the container if you make changes in top.env

    I believe the hash is only going to calculate changes based on the resolved environment variables. So if you make a change that results in the same key/value pairs, it won't result in a recreate.

    I added a new environment variable to top.env and it did trigger a recreate. Maybe there's some other edge case?

  6. krasi-georgiev commented on Nov 23, 2015

    @krasi-georgiev
    Author

    yes I tested the new branch you created
    and you are 100% right it does trigger the recreate properly

    so this definitely solves my case

  7. self-assigned this
    on Nov 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions