简体   繁体   English

在 Visual Studio Code Remote 中显示重定向 - WSL2 上的容器?

[英]DISPLAY redirection in Visual Studio Code Remote - Containers on WSL2?

I'm trying to use VSCode with WSL 2 and Remote-Containers to develop inside the container but I'm unable to redirect the display for viewing the opencv / matplotlib images.我正在尝试使用带有 WSL 2 和 Remote-Containers 的 VSCode 在容器内进行开发,但我无法重定向显示以查看 opencv / matplotlib 图像。

I have VcXsrv installed and used in combination with docker containers in PyCharm successfully and I'm trying to transfer the knowledge to be able to work directly in containers.我已成功安装 VcXsrv 并将其与 PyCharm 中的 docker 容器结合使用,并且我正在尝试转移知识以便能够直接在容器中工作。 However I had no luck in configuring the devcontainer.json in simmilar fasion:但是,我在以类似方式配置 devcontainer.json 时运气不佳:

I tried adding:我尝试添加:

"runArgs": [
        "--net", "host", 
        "-e", "DISPLAY=X.X.X.X:0.0",
        "-v", "/tmp/.X11-unix:/tmp/.X11-unix"
]

to devcontainer.json, which feels wrong anyway.到 devcontainer.json,反正感觉不对。

I can eventually start the VSCode from MobaxTerm WSL which has its own X server, but I havent find the way to configure the container for that either.我最终可以从拥有自己的 X 服务器的 MobaxTerm WSL 启动 VSCode,但我也没有找到为此配置容器的方法。

Anybody has any experience?有人有经验吗?

So in the end it is necessary to have vcxsrv configured with -a -c and "access control disabled".所以最后有必要用 -a -c 和“禁用访问控制”配置 vcxsrv。 Then it is possible to那么就可以

export DISPLAY=X.X.X.X:0.0

in VSCode bash terminal in the container.在容器中的 VSCode bash 端子中。

That did the trick.那成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM