问题
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}
GIT_URL=git@github.com:some-org/${APP_ENV}
What is the supported form of variable substitutions in env_file???
回答1:
Variable substitution is not supported in env_file.
Your options are:
- use variables in the
environment:section (although you wont be able to do your example because setting a value inenvironmentonly sets it for the container environment, and substitution happens on the host). - use host variables by specifying an environment variable without a value (ex:
LOCALPATH=), which may be in either the env_file or environment section.
来源:https://stackoverflow.com/questions/35277472/how-to-do-variable-substitution-in-env-file