An environment variable is a named value a program can read. Compose can use variables in two places. It can substitute a value while reading the file, and it can pass values to a program inside a container.
Docker Compose · Lesson 5
Environment Variables
Learn to distinguish a value substituted into a Compose file from a value passed into a container.