Dynamic enviromental variable in docker-compose

hey all,

I have the following docker-compose.yml file:

web:
build: .
ports:
- "8085:80"
volumes:
- .:/var/www
environment:
- “DOCKER_HOST_IP=$(route -n | awk ‘/UG[ \t]/{print $2}’)”

I cannot seem to use a method inside the docker-compose file. Is there another way to do this besided creating a shell script and run that with CMD ?

thanks!