chrish February 2016

How to do variable substitution in env_file?

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???

Answers


dnephin February 2016

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 in environment only 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.

Post Status

Asked in February 2016
Viewed 2,180 times
Voted 6
Answered 1 times

Search




Leave an answer