Skip to content

Instantly share code, notes, and snippets.

@dnephin
Last active January 7, 2022 06:48
Show Gist options
  • Save dnephin/447b293cfca7099822d0 to your computer and use it in GitHub Desktop.
Save dnephin/447b293cfca7099822d0 to your computer and use it in GitHub Desktop.
docker-compose extends and environment variables
TEST_ONE=common-env-file
TEST_TWO=common-env-file
TEST_TREE=common-env-file
TEST_FOUR=common-env-file
top:
image: alpine:edge
env_file: top.env
command: sh -c "env | grep TEST | sort"
environment:
TEST_ONE: top
extends:
service: common
common:
image: alpine:edge
env_file: common.env
environment:
TEST_ONE: common
TEST_TWO: common
# docker-compose-1.4.2
top_1 | TEST_FOUR=common-env-file
top_1 | TEST_ONE=top
top_1 | TEST_TREE=top-env-file
top_1 | TEST_TWO=top-env-file
# docker-compose-1.5.0
top_1 | TEST_FOUR=common-env-file
top_1 | TEST_ONE=top
top_1 | TEST_TREE=top-env-file
top_1 | TEST_TWO=top-env-file
# docker-compose-1.5.1
top_1 | TEST_FOUR=common-env-file
top_1 | TEST_ONE=top
top_1 | TEST_TREE=common-env-file
top_1 | TEST_TWO=common
# docker-compose (with #2418)
top_1 | TEST_FOUR=common-env-file
top_1 | TEST_ONE=top
top_1 | TEST_TREE=common-env-file
top_1 | TEST_TWO=common
TEST_ONE=top-env-file
TEST_TWO=top-env-file
TEST_TREE=top-env-file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment