Home Ask Login Register

Developers Planet

Your answer is one click away!

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:


What is the supported form of variable substitutions in env_file???


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


Leave an answer

Quote of the day: live life