The env_file
parameter is for defining environment variables inside the running container. It will not be used for variable substitution in your docker-compose.yaml
file (as you have seen).
You have two options:
-
(1) You can run:
source image.env
before runningdocker-compose up
so that those environment variables are set in your system environment -
(2) You can rename
image.env
to.env
and then docker-compose will read them as environment variables to be used for substitution in yourdocker-compose.yaml
file.
I believe fo from your example that you want the second option.