Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

910
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda