Running a debugger for a python app running inside a docker.

Hello,

I've tried to debug a Python application that's running inside a docker container, but I got the following error:
bind: Only one usage of each socket address (protocol/network address/port) is normally permitted.

I'm using PyCharm Professional 2024.2 on Windows 10.

Could anyone help me set up the remote debugger?

My current steps:
I exposed the port in the docker-compose.yml file:
ports:
  - "8542:8542"

And created a Python Debug Server configuration, with the host being localhost and port being 8542.

Then, when I try to run both this debug configuration and the docker container I get an error saying the port is already in use. Basically it seems the debug configuration I set up is occupying the port instead of just listening to it. To be clear, when I run only the docker container or only the debug configuration (and not together), it works, since the port is not used by any other application.

 

Could somebody guide me on how to set up the remote debugger?

Thanks in advance!

1

Please sign in to leave a comment.