warnThe container sees warn. In Compose, environment wins over env_file. Both of them override the image's ENV.
The order from strongest to weakest is:
• docker compose run -e (this beats all the others)
• environment
• env_file
• the image's ENV
"The container fails because the variable is defined twice" is wrong. Defining a variable in several places is normal, and Compose simply picks the stronger one.
Read more
- Docker Compose (https://docs.docker.com/compose/)docs.docker.com