Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

909
Views
PyCharm remote debug in a docker container

I'm having an hard time trying to figure out how to setup a remote debug of a python app (Flask) running in a Docker container. Specifically I'm using docker-compose, PyCharm professional and python 3.5. This is what I've done so far:

  • I copied "pycharm-debug-py3k.egg" into the project folder
  • I added the following lines in the wsgi.py file:

    import sys
    sys.path.append('../pycharm-debug-py3k.egg') 
    import pydevd 
    pydevd.settrace('0.0.0.0', port=8200, stdoutToServer=True, stderrToServer=True)
    
  • I created a remote debug configuration in PyCharm (by mapping the path of my local machine project path to the one in the docker container)

by running the debug configuration (click on the bug icon) from PyCharm it prints (and hangs):

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...

...and in the docker container logs I read:

Could not connect to 0.0.0.0: 4200

What should I do? (My goal is to be able to add breakpoints in PyCharm and stop the execution of the docker container app in order to debug it)

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Use a remote interpreter, this will solve a couple of issues at once. I already answered this here Rich editors in a Docker development environment

Add a remote python SDK to your IDE, this will then also resolve all the libraries being installed remotely. You will require an SSH connection to get this done though, so install sshd and use the shared developer key I outlined in my answer.

Even though this now a bit more effort, I will give you a lot better results, also in the other sections you did not yet encounter and will find, when doing just a remote-port connection.

If you still want to use the port-based debugging, see Docker: MacOSX Expose Container ports to host machine - this explains how you should understand the attach and the listen part.

over 4 years ago · Santiago Trujillo Report

0

Use host.docker.internal instead of 0.0.0.0. This will allow docker to decide which IP to use.

over 4 years ago · Santiago Trujillo Report

0

Maybe you should connect to you self host machine that is you pycharm in. not 0.0.0.0 instead of you self ip address

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!