-
Notifications
You must be signed in to change notification settings - Fork 305
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
Remote-Container (docker-compose) Support for .env and/or COMPOSE_PROJECT_NAME variable #222
Comments
I specify the mysql port etc in the env file, and compose loads it. |
I hit the same issue, I am using the following structure
I am specifying the correct docker-compose path in the devcontainer.json and the context to also be but when reopening folder in container it errors as it can't find the env used in docker-compose.yml defined in the .env file Really looking forward to have support for this. edit: maybe an option to pass through args to docker-compose would be even better? |
@nolazybits @hareku The default It would work if you put it in the root of your project, but you can also add an
@chrmarti This is a bit confusing, so probably a good reason to support the context property. |
We currently use the project folder as the working directory for all command executions. We could change that to the folder of the docker-compose.yml, but that would break setups where the Does setting The |
@chrmarti Yes, you'd have to add it to every service, so it does solve the issue, but is a cumbersome solution. I've seen people ask about environment variables like this before due to how their command line workflow functions. Allowing context to work would give people the option to retain their current workflow. |
I think the Do we need a way to change the directory from which commands are run? (Reading https://docs.docker.com/compose/env-file/.) |
@chrmarti Yep, that's actually what context does for the Dockerfile case - it sets the working directory. This would be the same scenario which is why I can see why @nolazybits tried to use it. |
@chrmarti In fact, I wonder if we should't be including an env file our dev container definitions - particularly existing docker-compose / dockerfile to make this pattern a bit more obvious. |
My 2 cents - maybe using the context would be a good idea and then leave it to docker compose so you don't have to play catch if anything changes on their side (multiple env file for instance etc). |
Documentation and my tests show that
The feature request here is asking for supporting To expand on this we could add support for changing the current working directory when running |
We are experiencing same issue on our side, we are developing Laravel on laradock, laravel using .env file for own config at project directory. At laradock ( docker template) also .env file at their directory Our folders
In this case when we try to launch at vsCode in container, its reads .env file of laravel. Using env_file is not option for us, we need ENV config on build of docker compose (docker-compose.yml : https://github.com/laradock/laradock/blob/master/docker-compose.yml ) Here is some suggestions
Also at here is mentioned : #1299 |
tl,dr; Using .env file is the same thing as saying COMPOSE_PROJECT_NAME=foo docker-compose ... Note that .env and --env-file does not work exactly in the same way. --env-file passes environment variables to the instantiated container whereas .env files exposes environment variables to docker-compose and variable interpolation in its configuration files. those variables will not be passed to the instantiated container unless specified explicitly in an environment block. |
Unfortunately this doesn't seem to be true. I have two completely identical projects here, the only difference is the actual source code for the two applications. Each project has, directly in the root folder of the project, In the file explorer of the project windows, I see "SOURCE" as the heading, because "source" is the name of the folder that all these files and the application source code resides in. These files are listed as being directly that, which I believe means they are "in the root folder of the project" (there's no place higher up they can be and still be shown in the file explorer). The two projects have different We really need to make this extension aware of and use We know where the BTW, if it's not clear, I can verify that if I |
@Chuxel This is currently labeled as a feature request, but considering it's such a problem when using multiple projects and how common the use of The fixes that both I and others have suggested (simply look for a I fear that as long as this is called just a "feature request" it won't get any attention, and it's really a bug that it's not working properly with the project names defined in accordance with official Docker Compose documentation. |
This vscode remote containers bug is really bothering me. I've tried putting a |
Yeah. Considering how insanely easy this problem is to fix, it's baffling that Microsoft doesn't fix it, despite all these comments and clear evidence that it's a real problem and makes serious docker compose usage impossible. |
Got a mail today; "Closed #222 via 7b7aa9a5991f7c6a61ac228b064d9051a3732b59". |
OMG is this closed and due out soon? AWESOME 😀 |
i have so now i have to copy that should i file another issue for this case? |
@art-in Yes, please file a new issue. Thanks. |
Hello,
Currently, VSCode try to recreate the entire docker-compose stack using the base directory as a project name (docker-compose default) because it ignores the .env file containing the actual project name to use in docker-compose.
Would be nice to either consider COMPOSE_* variables defined in the .env file (as docker-compose does it), or simply give us the possibility to provide that env variable directly in the .devcontainer.json file
Thanks in advance,
Loic
The text was updated successfully, but these errors were encountered: