Steps to Reproduce:
According to the documentation: "VS Code will automatically pick up a file called .env in your workspace root". However, the environment variable is not present in the terminal when running env.
Note that if you explicity load the .env file using "runArgs": ["--env-file","${localWorkspaceFolder}/.env"], then the env variable is present
Present as well here:
VSCode Version: 1.46.0
Local OS Version: archlinux 5.6.15-arch1-1
Remote Extension/Connection Type: Docker
According to the docs: https://code.visualstudio.com/docs/remote/containers-advanced
Edit devcontainer.json and add a path to the .env file relative to the location of devcontainer.json
However, the env file is also not detected relative to the devcontainer.json path. The fix including ${localWorkspaceFolder}/path/to/env does resolve the issue. Regression or should docs be updated?
The documentation needs a small update: .env is only picked up automatically by docker-compose. docker and docker-compose both support explicitly specifying an env-file as described in the documentation.
Good to know I wasn't crazy! And I have gotten the .env file to work with a docker-compose.yml file, so I can confirm it does work in that case. Unfortunately, I was trying to make my project setup work for the 'open from repository' feature, which doesn't work with docker-compose-based .devcontainer configurations.
Most helpful comment
The documentation needs a small update:
.envis only picked up automatically bydocker-compose.dockeranddocker-composeboth support explicitly specifying an env-file as described in the documentation.