Docker Compose: Override configuration via an environment var
Here is a simple way to override a variable in your docker-compose.yml file.
Using this syntax it will first try to get the environment variable named “MY_PROFILE” from your computer and pass it to the container, if it’s not set, it will use the value “dev”.
docker-compose.yml
Environment variable "MY_PROFILE" not set
Environment variable "MY_PROFILE" set
Versions used
- Docker: 17.06.0-ce
- Docker Compose: 1.14.0
- docker-compose.yml file format: 2.1
- OS: Windows 10