Compose supports declaring default environment variables in an environment file named .env placed in the folder where the docker-compose command is executed (current working directory).
Example: The below example demonstrate how to declare default environmental variable for Docker Compose.
$ cat .env
$ cat docker-compose.yml
When you run docker-compose up, the web service defined above uses the image webapp:v1.5. You can verify this with the `docker-compose config` command which prints your resolved application config to the terminal.
$ docker-compose config