Visual Studio代码被远程调试附着到烧瓶应用搬运工容器
问题描述:
我目前从原子切换到Visual Studio代码期间卡住。Visual Studio代码被远程调试附着到烧瓶应用搬运工容器
不幸我不能得到远程调试在以下设置运行:
网/ app.py
from flask import Flask
app = Flask(__name__)
import ptvsd
try:
ptvsd.enable_attach(secret=None, address = ('0.0.0.0', 3000))
ptvsd.wait_for_attach()
ptvsd.break_into_debugger()
except:
pass
@app.route('/')
def hello_world():
return 'Flask Dockerized'
if __name__ == '__main__':
app.run(debug=False,host='0.0.0.0', port=5000)
泊坞窗,compose.yml
web:
build: ./web
ports:
- "5000:5000"
- "3000:3000"
volumes:
- .:/code
launch.json
{
"name": "Attach (Remote Debug)",
"type": "python",
"request": "attach",
"localRoot": "${workspaceRoot}",
"remoteRoot": "${workspaceRoot}",
"port": 3000,
"secret": "",
"host": "localhost"
}
问题:当我运行搬运工,撰写我得到:
starting container flaskdocker ...
starting container flaskdocker ... done
attaching to flaskdocker
它只是被卡在那里,我不能访问端口烧瓶应用:5000(安装前的工作完美调试到它)。
为什么? :/ 请帮忙!
我在使用Visual Studio Code 1.15.1的macOS上。
答
使用ptvsd> 3.0.0从Visual Studio Code进行远程调试时报告了一些问题。
最经常提到的问题是,当试图连接到远程调试器时,VSC'挂起'。
现在,使用ptvsd 3.0.0:pip install ptvsd==3.0.0
询问异地资源,如教程是**题外话**,所以我删除了,从你的问题。请花一些时间在[帮助]了解如何/在这里问什么。 – GhostCat
如果您检查Visual Studio代码的控制台,您将看到巨大的JS错误。这是导致事情不起作用的原因。看到这个线程的一些信息https://stackoverflow.com/questions/45647124/visual-studio-code-how-to-remote-debug-python-code-in-a-docker-container/45649274#45649274 –
这里一台Ubuntu机器,我用telnet和netcat检查了端口通信。在wait_for_attach()之后,ptvsd很好地发出一个json字符串并进行监听。这只是VS Code保持沉默。在Windows PC上使用Visual Studio时,在Linux机器上附加进程时没有问题。看来,VS Code的ptvsd支持刚刚破裂。 – thomiel