Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devcontainer.json does not pick up parameters from the env file and does not pass them to docker-compose #6586

Open
avraam-inside opened this issue Apr 5, 2022 · 3 comments
Assignees
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality
Milestone

Comments

@avraam-inside
Copy link

I need to pass the path to the project folder at one point from somewhere (from under the env file or devcontainer).

Unfortunately, now we have to duplicate it, because we could not link devcontainer with docker-compose at all.

Please fix/modify.

@lszomoru lszomoru assigned chrmarti and unassigned lszomoru Apr 5, 2022
@chrmarti chrmarti transferred this issue from microsoft/vscode Apr 8, 2022
@chrmarti
Copy link
Contributor

chrmarti commented Apr 8, 2022

docker-compose will pick up a .env file in the same folder as the (first) docker-compose.yml. Does that help?

@chrmarti chrmarti added containers Issue in vscode-remote containers info-needed Issue requires more information from poster labels Apr 8, 2022
@avraam-inside
Copy link
Author

avraam-inside commented Apr 8, 2022

@chrmarti Unfortunately, it doesn't help.

docker-compose.yml will pick it up. The point is how to pass parameters from .env file to devcontainer.json.

Or as from devcontainer.json pass variables to docker-compose.yml?

Now I have to duplicate variables both there and there.

The functionality presented in this documentation https://code.visualstudio.com/remote/advancedcontainers/environment-variables does not allow linking variables between devcontainer.json and docker-compose.yml

A concrete example: I need to change the workspaceFolder in devcontainer.json and at the same time register the same path in volumes in docker-compose. Now I do not know how to do this without duplicating this path in both files.

@chrmarti chrmarti added feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster labels Apr 11, 2022
@chrmarti chrmarti added this to the Backlog milestone Apr 11, 2022
@MadsRC
Copy link

MadsRC commented Jul 8, 2022

A workaround is using the initializeCommand setting in devcontainer.json to write to .env, which docker-compose will then pick up. Example: "initializeCommand": "echo \"${workspaceFolder}\" > .env"

The only reason I call it a workaround and not a solution is that it's no OS agnostic. You're passing a OS specific command, which might not work on Windows, MacOS or Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants