Replies: 4 comments 3 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
.envfile into thedocker-compose.ymlsetup with a pretty default project layout.My project layout is as follows:
I want to have in
docker-compose.ymla section to create a Postgres container with setting up the environment one by one:POSTGRES_USER,POSTGRES_PASSWORD, andPOSTGRES_DBand fill them with variables from the project's.envfile. The relevant section indocker-compose.ymlis:I do NOT want to have a copy of my
.envfile in the.devcontainer/folder, as it is the case in some of the DevContainer templates. This would work, as in this casedocker composeloads it by default. I don't want this organization, as the.envfile 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_fileoption in the docker compose service description.When building a container myself (just
docker, nodocker compose), I can add indevcontainer.jsonthe optionrunArgsnext to the optionbuildgiving the env-file information to docker:--env-file ../.envHowever, this is not possible when using a docker-compose setup invscodeandDevContainerswith"dockerComposeFile": "docker-compose.yml".https://containers.dev/implementors/json_reference/
At the command line
docker compose --env-file ../.env updoes the trick.So, my questions:
devcontainer.json?Beta Was this translation helpful? Give feedback.
All reactions