Reputation: 5787
I can use --env-file /path/to/.env
to define variables. Is there a way to define variable from previously defined variable in the same file? Example:
SOME_USER=good_user
ROOT_USER=$SOME_USER
Upvotes: 1
Views: 313
Reputation: 12199
As far as I know, it's only a simple list of values, nothing special such as templating or expansion and it's even broken for quotes so e.g. VAR="test"
will be actually a value of "test"
instead of test
.
The documentation also doesn't mention anything, or at least explicitly.
... simple (non-array) environment variables ...
... This file should use the syntax <variable>=value (which sets the variable to the given value) or <variable> (which takes the value from the local environment), and # for comments. ...
$ cat file.env
VAR=one
VAR2=$VAR
VAR3=${VAR}
$ docker run -it --env-file file.env busybox env | grep VAR
VAR=one
VAR2=$VAR
VAR3=${VAR}
Upvotes: 1