Additionally, if you really want to use the .env file, You can add this to your docker-compose.yml file:
env_file:
- <path_to_file>/.env
So if docker-compose.yml lives in the same directory as .env then you can leave out <path_to_file>/ in my example above.