Reputation: 2432
I am using docker-compose and I want my env_file to have variable subsitution. I would like to define one variable in the file and then use it in other variables:
APP_ENV=dev-foo
LOCALPATH=/tmp/builddir/${APP_ENV}
[email protected]:some-org/${APP_ENV}
What is the supported form of variable substitutions in env_file???
Upvotes: 17
Views: 6564
Reputation: 11709
Variable substitution is now supported in docker compose
The syntax is similar to shell substitution.
${VAR} -> value of VAR
${VAR:-default} -> value of VAR if set and non-empty, otherwise default
${VAR-default} -> value of VAR if set, otherwise default
${VAR:?error} -> value of VAR if set and non-empty, otherwise exit with error
${VAR?error} -> value of VAR if set, otherwise exit with error
${VAR:+replacement} -> replacement if VAR is set and non-empty, otherwise empty
${VAR+replacement} -> replacement if VAR is set, otherwise empty
EDIT: Do notice that using docker-compose
is deprecated and will not use the latest version. Use docker compose
(no dash), which will use the latest compose version.
Upvotes: 5