windows - 无法使用远程容器将 C/C++ 扩展安装到 VisualCode
问题描述
我无法使用“远程 - 容器”在开发容器中安装扩展。我想从现有的 docker 文件在容器中开发一些 C 应用程序。为此我设置了一个.devcontainer.json
{
"name": "Jenkins_virtual_env",
"dockerFile":"../container/Dockerfile",
// Use this environment variable if you need to bind mount your local source code into a new container.
"remoteEnv": {
"LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
},
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cpptools-extension-pack"
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
//"forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "docker --version",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
//"remoteUser": "vscode"
}
现在在“ReOpen in Container”之后,容器启动,我可以在这个容器中执行命令。但是,当启动安装扩展时,会显示错误。
Updating C/C++ dependencies...
Downloading package 'C/C++ language components (Linux / x86_64)' Failed. Retrying... Failed. Retrying... Failed. Retrying...Waiting 8 seconds... Failed. Retrying...Waiting 16 seconds... Failed to download https://go.microsoft.com/fwlink/?linkid=2155055
Failed at stage: downloadPackages
Error: connect ECONNREFUSED 127.0.0.1:9000
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
If you work in an offline environment or repeatedly see this error, try downloading a version of the extension with all the dependencies pre-included from https://github.com/microsoft/vscode-cpptools/releases, then use the "Install from VSIX" command in VS Code to install it.
我不确定谁想要连接到 localhost:9000 但我猜它是容器内的一个应用程序。我看到的是,容器中似乎有一个端口转发处于活动状态。
关于设置的一些事实:
- VisualCode 版本 v1.53.2
- ms-vscode-remote.remote-containers v0.158.0
- ms-vscode.cpptools v1.2.1
- 系统:Windows 10 企业版 1909
- 使用基于 WSL2 的镜像使用 Docker4Windows v20.10.2
我已经检查了什么:为了避免在我的 dockerfile 中排除错误,我回到了 microsoft 默认 c++ 映像(https://github.com/microsoft/vscode-remote-try-cpp)。我还检查了主机系统上使用的端口。我发现,端口 9000 已被 zscaler 使用。但是 Code.exe 正在侦听端口 9001(适合转发的 docker 端口)。
我还使用了 中的“appPort”选项.devcontainer.json
,唯一的效果是,我在容器和主机之间看到了一个额外的隧道。错误消息保持不变。
有没有人对此有想法,或者可能有一些提示如何进行更深入的调查?我不知道哪个组件导致了这个问题('C/C++ 扩展'或'远程容器'或'VCS'本身......或一些隐藏的组件)。
解决方案
推荐阅读
- swift - How can I change the date format in Swift5 (ISO8601)?
- r - 如何在迭代添加一个时基于组添加行?
- asp.net-mvc - 如何在 ASP.NET MVC 中从视图中调用 ViewComponents?
- java - Spring Security:身份验证导致 HTTP 405“方法不允许”
- javascript - 如何将从表单收到的信息发送到将存储它们的按钮链接,并在点击时显示它们?
- reactjs - 返回 Promise 的函数的 redux-saga yield 或 call() 导致其他 saga 无需等待即可运行
- javascript - 为事件中心输出绑定设置 partitionKey
- python - 熊猫滚动标准开发行为
- json - 不显示价值
- java - JasperReports - 在 Java 中运行时 JSON 数据报告显示空值