Remote Containers - Allow to specify --project-directory for docker-compose #2323
Labels
containers
Issue in vscode-remote containers
feature-request
Request for new features or functionality
plan-review
PM-highlighted item determined to be P1 or P2
Hi, I like the idea of
Remote - Containers
. I'm making examples to understand and see how things work with this extension.I've tried following the steps with Connecting to Multiple Containers at Once, with my own twists where I tried to use a shared
.env
file.The Problem
I have this structure:
.env
With the
remote - containers
extension, if you follow the official instructions here, where you'd use the commandRemote-Containers: Open Folder in Container...
, it won't actually work and would just error out. The problem is it'll open the folder where the.devcontainer.json
file resides. Thedocker-compose
command's working directory would also be where this.devcontainer.json
file resides.The implications of this is it'll try to find and use the
.env
file from the directory where the.devcontainer.json
file resides (which of course, doesn't exists). As it doesn't exist in that directory, the.env
file isn't used, meaning the environment variables doesn't get imported, causing the extension to fail.To reproduce this issue, you can clone my example repo, then remove the two
.env
(i.e.WebApp/.env
&WebApi/.env
) files, and then follow the README instructions.Workaround
Thus, currently the only way to get it to work is you'll need to copy your
.env
file to be where the.devcontainer.json
file resides. That is, you'd have the below structure where you.env
file is duplicated..env
.env
This isn't really an ideal solution as you'd duplicate the
.env
file multiple times, needing to maintain all of them.To reproduce this workaround, you can clone my example repo and then follow the README instructions.
Possible Solution
This can be resolved if the extension lets us somehow specify the option
--project-directory
fordocker-compose
, perhaps in the.devcontainer
.For more information on
--project-directory
, see:The text was updated successfully, but these errors were encountered: