'How to set env variables from root env file while building docker containers

I've folder structure like this,

service-1
- Dockerfile
service-2
- Dockerfile
.env
docker-compose.yml

Now I need to get it working in a way that Dockerfile can access root level .env file while building services.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source