The statement that describes the dockerComposeFile property in devcontainer.json (https://containers.dev/implementors/json_reference/):
"The default .env file is picked up from the root of the project, but you can use env_file in your Docker Compose file to specify an alternate location."
seems confusing as it refers to two different things.
See: https://stackoverflow.com/questions/79305196/docker-compose-file-is-not-using-env-variables
.env file: used for interpolation in the Compose file and to configure some configs. Variables here can be passed individually to the container via the environment attribute (e.g., LANG=${LANG}), or passed as a whole via the env_file.
see: https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/#env-file
env_file: sets the container's environment; this does not pass the .env file automatically into the container unless explicitly passed like (- path: .env).
see: https://docs.docker.com/compose/how-tos/environment-variables/set-environment-variables/#use-the-env_file-attribute
The statement that describes the dockerComposeFile property in devcontainer.json (https://containers.dev/implementors/json_reference/):
"The default .env file is picked up from the root of the project, but you can use env_file in your Docker Compose file to specify an alternate location."
seems confusing as it refers to two different things.
See: https://stackoverflow.com/questions/79305196/docker-compose-file-is-not-using-env-variables
.env file: used for interpolation in the Compose file and to configure some configs. Variables here can be passed individually to the container via the environment attribute (e.g., LANG=${LANG}), or passed as a whole via the env_file.
see: https://docs.docker.com/compose/how-tos/environment-variables/variable-interpolation/#env-file
env_file: sets the container's environment; this does not pass the .env file automatically into the container unless explicitly passed like (- path: .env).
see: https://docs.docker.com/compose/how-tos/environment-variables/set-environment-variables/#use-the-env_file-attribute