docker-compose.yaml inside .devcontainer can't access env vars from .env file outside during build #225
Unanswered
Dima-Bulavenko
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
HI, I'm trying to use a
.env
file located outside the.devcontainer/
folder to provide build arguments todocker-compose.yaml
during a Dev Container setup.However, since
docker-compose.yaml
is placed inside.devcontainer/
, it doesn't pick up environment variables from the.env
file in the parent directory during build-time. As a result, theargs
like${PYTHON_VERSION}
are empty when the image builds.I’d like to avoid duplicating the
.env
file by copying it into.devcontainer/
.📁 Folder Structure
📄 .env
📄 .devcontainer/devcontainer.json
📄 .devcontainer/docker-compose.yaml
🧪 Additional Note
When I placed
docker-compose.yaml
at the same level as the.env
file, everything worked fine — the variables were picked up during build. But that’s not possible in my case because Dev Containers requiredocker-compose.yaml
to be inside.devcontainer/
.❓ Question
How can I configure the Dev Container so that:
docker-compose.yaml
(inside.devcontainer/
) uses a.env
file from the parent folder.env
variables are correctly passed as build-time args.env
file inside.devcontainer/
Is there an officially supported way to handle this setup?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions