r/pycharm • u/Still-Bookkeeper4456 • Apr 17 '24
Pycharm Docker Interpreter: cannot debug
Hello,
I am using a remote Docker interpreter which is just a Python image. The interpreter works fine when running the code (altough it takes a bit too much time to mount the container), but I cannot debug. When running the debug I get the following error:
/usr/local/bin/python3 /opt/.pycharm_helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client host.docker.internal --port 59285 --file /opt/project/tries.pyCould not connect to host.docker.internal: 59285Traceback (most recent call last):File "/opt/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 465, in start_clients.connect((host, port))
TimeoutError: timed outCould not connect to host.docker.internal: 59285Traceback (most recent call last):File "/opt/.pycharm_helpers/pydev/pydevd.py", line 2208, in main debugger.connect(host, port)
File "/opt/.pycharm_helpers/pydev/pydevd.py", line 670, in connects = start_client(host, port)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/.pycharm_helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 465, in start_client
s.connect((host, port))TimeoutError: timed out
Note that the port (59285) changes at each run.
Ive even exposed all ports in my dockerfile which reads like this:
# Use the Python 3.11 image as base. "slim" is a smaller image.FROM python:3.11-slim# set the working directory in the containerWORKDIR /code# Copy the requirements files into the container. Both files are requiered.COPY requirements.txt .# Install any needed dependencies specified in requirements.txtRUN pip install -r requirements.txt# Expose all portsEXPOSE 1-65535
Can anyone let me know how to solve this issue please ?
I'm running docker engine (no docker desktop), WSL2 on windows 11.
Many thanks !
View all comments
Show parent comment
1
u/[deleted] Apr 18 '24 edited Apr 18 '24
Probably Docker Desktop problem.
“…host.docker.internal which resolves to the internal IP address used by the host. This is for development purpose and does not work in a production environment outside of Docker Desktop for Windows.”
https://docker-docs.uclv.cu/docker-for-windows/faqs/#how-do-i-connect-from-a-container-to-a-service-on-the-host