<p>我很难弄清楚如何设置在Docker容器中运行的python应用程序(Flask)的远程调试。
具体来说,我使用的是docker compose、PyCharm professional和python 3.5。
这就是我到目前为止所做的:</p>
<ul>
<li>我将“pycharm-debug-py3k.egg”复制到项目文件夹中</li>
<li><p>我在wsgi.py文件中添加了以下行:</p>
<pre><code>import sys
sys.path.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>('../pycharm-debug-py3k.egg')
import pydevd
pydevd.settrace('0.0.0.0', port=8200, stdoutToServer=True, stderrToServer=True)
</code></pre></li>
<li><p>我在PyCharm中创建了一个远程调试配置(通过将本地计算机项目路径映射到docker容器中的路径)</p></li>
</ul>
<p>通过从PyCharm运行调试配置(单击bug图标),它将打印(并挂起):</p>
<pre><code>Starting debug server at port 4200
Use the following code to connect to the debugger:
import pydevd
pydevd.settrace('0.0.0.0', port=4200, stdoutToServer=True, stderrToServer=True)
Waiting for process connection...
</code></pre>
<p>…在docker容器日志中我读到:</p>
<blockquote>
<p>Could not connect to 0.0.0.0: 4200</p>
</blockquote>
<p>我该怎么办?(我的目标是能够在PyCharm中添加断点,并停止docker容器应用程序的执行以进行调试)</p>