I have a docker-compose.yaml
file and a .env
file. If I declare a variable in the env file, I can access it in docker-compose. So, this is good.
But, I would like to change nginx's default.conf
properties, namely the server_name = xxx
to be generated from the value I provide in the env.
So, my env looks like this (only sharing a portion)
#.env
NGINX_SERVER_NAME=dev.example
In docker-compose I mention this variable here:
nginx:
container_name: ${APP_NAME}-server
environment:
- SERVER_NAME=${NGINX_SERVER_NAME}
And in default.conf
I simple call the variable like this:
server_name ${SERVER_NAME};
I am expecting the default.conf
to contain server_name dev.example
but it contains the token i.e. ${SERVER_NAME}
How can I achieve what I am looking for? Thanks