Man*_*red 11 visual-studio-code vscode-remote vscode-devcontainer
我的设置是带有开发容器的 VS Code。当我启动一个生成类似于 URL 的输出的应用程序时,VS Code 将提取端口号并自动转发该端口。此处详细描述了此过程。
我的问题有两个:
自动转发端口有什么好处?
如何有效防止 VS Code 自动转发任意端口?
我考虑和测试的解决方案包括使用以下设置:
{
// Prevent VS Code's automatic port forwarding
"remote.autoForwardPorts": false,
"remote.restoreForwardedPorts": false,
"remote.portsAttributes": {
"1-65000": {
"label": "Application",
"onAutoForward": "ignore"
}
},
}
Run Code Online (Sandbox Code Playgroud)
我已经在用户级别、开发容器级别(也称为远程)和工作区级别尝试了这些设置。此外,我也尝试过这些设置devcontainer.json
。我还重建了开发容器以确保应用设置。
然而,我在这方面运气并不好。VS Code 会自动转发端口。我正在寻找持久的解决方案。
我检查了devcontainer.json 参考文档和端口属性。
\n我认为您需要以下设置devcontainer.json
\n\n\n
otherPortsAttributes
:使用\xe2\x80\x99t 配置的端口、端口范围和主机的默认选项portsAttributes
\n\n\n
onAutoForward
:值表示ignore
该端口根本不应该自动转发。
{\n "otherPortsAttributes": { "onAutoForward" : "ignore" }\n}\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
7890 次 |
最近记录: |