Replies: 4 comments 2 replies
-
Thanks for open this discussion. I've cross-posted this in our dev container community Slack channel to get some more perspectives. And if you'd like to join our community Slack, we'd love to have you join! https://github.com/orgs/devcontainers/discussions/3 |
Beta Was this translation helpful? Give feedback.
-
Hi 👋 Can you add the following to your
|
Beta Was this translation helpful? Give feedback.
-
There is a feature request for the Dev Containers extension to support |
Beta Was this translation helpful? Give feedback.
-
Is there a solution for this problem? I am getting issues to use a .env file in devcontainer |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I don't get the environment variables from my project's
.env
file into thedocker-compose.yml
setup with a pretty default project layout.My project layout is as follows:
I want to have in
docker-compose.yml
a section to create a Postgres container with setting up the environment one by one:POSTGRES_USER
,POSTGRES_PASSWORD
, andPOSTGRES_DB
and fill them with variables from the project's.env
file. The relevant section indocker-compose.yml
is:I do NOT want to have a copy of my
.env
file in the.devcontainer/
folder, as it is the case in some of the DevContainer templates. This would work, as in this casedocker compose
loads it by default. I don't want this organization, as the.env
file is also needed by the project's code and expected in the project root.I also don't want to expose the whole
.env
-file to my container, which I could do with theenv_file
option in the docker compose service description.When building a container myself (just
docker
, nodocker compose
), I can add indevcontainer.json
the optionrunArgs
next to the optionbuild
giving the env-file information to docker:--env-file ../.env
However, this is not possible when using a docker-compose setup invscode
andDevContainers
with"dockerComposeFile": "docker-compose.yml"
.https://containers.dev/implementors/json_reference/
At the command line
docker compose --env-file ../.env up
does the trick.So, my questions:
devcontainer.json
?Beta Was this translation helpful? Give feedback.
All reactions