title: How to set up flask for debugging in visual studio code using docker compose
body: <p>I have a flask web app that runs in a handful of containers that I manage with docker-compose. I have been working through the <a href="https://code.visualstudio.com/docs/remote/containers" rel="nofollow noreferrer">instructions</a> to set up Visual Studio Code with the Remote Development extensions to work on my code within my container. So far so good, I have been able use my existing docker compose file and connect to the remote container as advertised. The docker compose file starts my flask development server as that container's entry point. I'd like to be able to run a debugger on the flask app in vscode. The <a href="https://code.visualstudio.com/docs/remote/containers#_debugging-in-a-container" rel="nofollow noreferrer">documentation</a> on that is pretty sparse. </p>
  
  <p>I have been trying to follow the directions <a href="https://code.visualstudio.com/docs/python/tutorial-flask#_run-the-app-in-the-debugger" rel="nofollow noreferrer">here</a> to set up flask debugging, but the configuration is just different enough to not quite work right. I've tried changing my entry point bash script to detect an environment variable and not start flask when I want to debug. Then when I create a debug launch configuration in the container I am unable to go to the app in my browser even though the port (5000) is opened to the container. </p>
  
  <p>Visual Studio Dev Containers window</p>
  
  <pre><code>*
  * Reminder: You may only use this software with Visual Studio family products,
  * as described in the license https://aka.ms/vscode-remote/license
  *
  
  
  IP Address: 172.22.0.7
  Extension host agent listening on 33863
  Run: docker exec -w /root/.vscode-server-insiders/bin/553cfb2c2205db5f15f3ee8395bbd5cf066d357d 79e95283c8b7ae130fc09bb6e03d28627e970052feeee39a43e47622778239c4 /bin/sh -c echo 33863 &gt;.devport
  
  
  ------------------------
  Published Ports:
  5000/tcp -&gt; 0.0.0.0:5000
  ------------------------
  
  ==&gt; Received a management connection
  ==&gt; Received an extension host connection.
  ==&gt; Using UI language: en
  ==&gt; Received a management connection
  
  </code></pre>
  
  <p>Debug console window</p>
  
  <pre><code># cd /usr/src/app ; env PYTHONIOENCODING=UTF-8 PYTHONUNBUFFERED=1 /usr/local/bin/python /root/.vscode-server-insiders/extensions/ms-python.python-2019.5.17517/pythonFiles/ptvsd_launcher.py --default --client --host localhost --port 35381 -m flask run --no-debugger --no-reload 
   * Serving Flask app "resstockweb:app"
   * Environment: development
   * Debug mode: off
   * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
  </code></pre>