【发布时间】:2020-04-30 18:04:25
【问题描述】:
我阅读了许多类似的问题,但找不到任何适合我的答案。我还浏览了文档:here 和 here。
我在 Windows 上运行一个 Ubuntu 容器,我读到了 limitation in Networking。
我使用 -p 3000:3000 运行容器
错误 => 连接 ETIMEDOUT
这是我的 launch.json
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"port": 3000,
"host": "172.17.0.2",
"pathMappings": [
{
"localRoot": "${workspaceFolder}/somefolder/somefolder",
"remoteRoot": "/rootfolder/"
}
]
},
这是我的tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"type": "docker-build",
"label": "docker-build",
"platform": "python",
"dockerBuild": {
"tag": "test:latest",
"dockerfile": "${workspaceFolder}/somefolder/somefolder",
"context": "${workspaceFolder}",
"pull": true
}
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": ["docker-build"],
"python": {
"module": "C:\\...\\somefolder"
}
}
]
}
【问题讨论】:
-
你试过 VS Code 的 remote extensions 吗?
-
嗨,谢谢我采用了你的解决方案,它正在工作。如果您愿意,可以通过链接发布答案。
-
我之前因为发布基本上只是链接的答案而遇到麻烦,但我们会试一试,看看是否有人反对。
-
由于没有人提供可以直接解决我的问题的答案,我将暂时接受您的答案作为我的问题的替代和有效解决方案。如果有人反对,我可以删除这个问题。再次感谢。
标签: python visual-studio-code remote-debugging docker-container