devcontainers / devcontainers/spec

Confusing statement about .env and env_file in dockerComposeFile docs

Open
#738 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
5.7k
Forks
496
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.