Devcontainer and WSL
已回答
Hi,
I try to open/create a devcontainer from a .devcontainer.json with Gateway under windows. The .decvcontainer lies in a WSL2 distro (ubuntu). I export som environment variables in my .bashrc, which are used in the .devcontainer.json to set a mount path. When I open the devcontainer with VSCode, the mount works, but when I open it with Gateway it fails with “invalid mount config …”. I cant find any documentation regarding environment variables. Is there something I can do, that I have access to them while building the devcontainer? Frankly I'm not sure In which environment the actual container build happens win or wsl …
Thanks
Sebastian
BTW: The container works fine, when I use hardcoded paths in the .devcontainer.json
请先登录再写评论。
I'm encountering the same issue on Pycharm!
This is with me the activating it with the blue banner “Try the improved WSL2 setup…”
But I found that if I press the “New Project” → Dropdown →"Connect to Host" AND THEN connect to the devcontainer, it works.
@fnf mods You are right, the problem is that VSCode Gateway cannot access environment variables from .bashrc when setting up mount, so have to use VSCode variables or fixed paths.
Hello, Sebastian. Could you please specify where exactly your Docker is located, on Windows (Docker Desktop) or in the WSL?
Electrotiger, do I understand correctly that you start the Remote Development in the WSL first, and then build the dev container from there? Or just start the already created dev container?
Thanks for your replies. The Problem seems indeed to be, that there are environment variables involved which are only available to the VSCode environment. The format is something like §{localEnv:MY_VARIABLE} and there apparently are different scopes (containerEnv and remoteEnv) availble. But as I understand it these variables only function in VSCode environments.
As for your question, I use docker inside WSL. I have it mostly up and running now, but I frankly don't know how I got there anymore. I find all this remote development within WSL highly unstable at the moment. But even if I'm struggling with crashes and out of memory problems, part of it lies in the project I'm working on, which seems a bit overcomplicated to me. One of the latest issues I had, that from time to time I had to restart my docker and docker.socket, because the builder couldnt mount /usr/lib/wsl for some reason. I searched for hours, only to learn at some point, that restarting the aforementioned service. (This has nothing to do with JetBrains IDEs, but it illustrates the frustration ..)
Anyway I'm using the Gateway app now to start my dev containers and can work with this setup to some extend. I would nevertheless appreciate some good sources or articles which cover devcontainer-development with JetBrains IDEs.
Tanks again for your help
Sebastian
And I keep getting this annoying error: Can't retrieve image ID from build stream. Even when I add “options”: “--load”
:(
Please note that you can just open the WSL project without Remote Development or dev containers in the IDE installed on Windows. All you need to do is use the
File | Open…action (or any other similar one) and navigate to the WSL directory containing your project.We don't have any special documentation about the development in the containers; only these articles about how to build a dev container and these ones about the underlying Remote Development technology.
Could you please specify if your dev container configuration image-, Dockerfile- or Docker Compose-based? I want to try to reproduce it on my side.