PyCharm remote debug times out

Hey,

 

I'm trying to debug my code in a docker container on my local PC. I set up a remote interpreter to use docker compose which pulls up the container as I expect it, but stops it after a few secs of waiting cause the debugger times out trying to connect to the remote python debugger. Might worth to mention that I need GPU capabilities to debug my code, so I had to edit the system-wide docker settings to use the nvidia runtime by default. My understanding is that this shouldn't affect non-GPU capable dockers, or the networking in them whatsoever. Since docker is on my own PC I set up a normal Python run/debug cfg, not a remote python debug cfg.

 

My compose.yml specifies network_mode: "host".

All the output I get is:
Connection to Python debugger failed: Connection to the debugger script at 127.0.0.1:50480 timed out

Any suggestions?

Cheers,

P

6 comments
Comment actions Permalink

Hi,

Can you please try commenting out the `network_mode: "host"` option and see if it changes the behavior of the debugger (also try without the -i option)? Was it working before with other images? 

If that doesn't help, please try removing the generated images (with `docker image rm`), recreate the project interpreter, and rebuild the images again. If the issue is still reproduced, can you please reproduce the issue in a new project without any sensitive code and upload to our FTP (https://uploads.services.jetbrains.com/) ?

0
Comment actions Permalink

Hi,

I'm having the same problem. I use the standard docker-compose network settings (bridge). Interpreter and hot-reloading with watchdog into containers is working fine. I have removed and recreated all images, tried creating a completely new project and running the bugger from there without any luck.

I'm running a new installation of debian 9 (ran windows b4), therefore i don't know if this issue is a new or not.

0
Comment actions Permalink

Here are some more information:

Docker-compose file:

version: '3'
services:
webapp:
image: webapp:local
volumes:
- ./web_app/:/code
entrypoint: watchmedo auto-restart --recursive --pattern="*.py" --directory="." -- python /code/app/run.py
ports:
- "8000:8000"
depends_on:
- userservice
environment:
- DEBUG=True

web-test:
image: webapp:local
volumes:
- ./web_app/:/code
environment:
- PYTHONDONTWRITEBYTECODE=1
entrypoint: watchmedo auto-restart --recursive --pattern="*.py" --directory="." pytest
depends_on:
- webapp

userservice:
image: userservice:local
volumes:
- ./user_service/:/code
entrypoint: watchmedo auto-restart --recursive --pattern="*.py" --directory="." -- python /code/api/run.py
ports:
- "8002:8002"
depends_on:
- db
environment:
- DEBUG=True
- SECRET_KEY=xxx
- DB_URL=postgresql://xxx:xxx@db:5432/shoppa_test

userservice-test:
image: userservice:local
volumes:
- ./user_service/:/code
environment:
- PYTHONDONTWRITEBYTECODE=1
entrypoint: watchmedo auto-restart --recursive --pattern="*.py" --directory="." pytest
depends_on:
- userservice


db:
image: postgres
ports:
- "8001:5432"
volumes:
- db-data:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: xxx
POSTGRES_USER: xxx

volumes:
db-data:
driver: local

docker network inspect container:

[
{
"Name": "shoppa_default",
"Id": "ef9c2f9aff977fce980404d76155ad262f4b0fbb1bd47b7e2c1afe849873465a",
"Created": "2019-03-16T04:07:08.790367194+01:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"7f9ffd39f6f15b0ff6238fcf6a9006a387b9999927af5b818312ac91eccc9d1a": {
"Name": "shoppa_userservice-test_1",
"EndpointID": "fb6fbed33932f2e60fd6e1f929828d55596cf5896fc4dcafc49cae29e2cfbc6d",
"MacAddress": "02:42:ac:12:00:04",
"IPv4Address": "172.18.0.4/16",
"IPv6Address": ""
},
"8f108ac443b2646af23f4f82c665c23c20b771a2d940ed5d1923cd8b0d3168f8": {
"Name": "shoppa_db_1",
"EndpointID": "7103a5e61bdac1f46e435c89b441910035ee2318a1933b93499676ad159b244b",
"MacAddress": "02:42:ac:12:00:02",
"IPv4Address": "172.18.0.2/16",
"IPv6Address": ""
},
"951450e98f98e718389aa4999ed93c6603054482ae01f509c5a336798d279ae3": {
"Name": "shoppa_webapp_1",
"EndpointID": "757d6ce929789a5fe4feb91c9065421fbdea92928fb41135d834fc38c982cfa8",
"MacAddress": "02:42:ac:12:00:05",
"IPv4Address": "172.18.0.5/16",
"IPv6Address": ""
},
"c2092fb2ed1a0ec6748196c230453fb299b37ddfdf9c4ec6deaa9193e896070f": {
"Name": "shoppa_web-test_1",
"EndpointID": "3554a89a10930f4f444579e378c8d22c781c7ca9c61fd8dc59376c1e9f360c96",
"MacAddress": "02:42:ac:12:00:06",
"IPv4Address": "172.18.0.6/16",
"IPv6Address": ""
},
"d4ac35e616a0965d49fb20237eca25fc4515fb4fc5e52d0b0889cab070a80a33": {
"Name": "shoppa_userservice_1",
"EndpointID": "8a671e6a00d06730c46e89e3c914cc8ee24a0e85fd9ac2d3f6a00cf2e7e4d948",
"MacAddress": "02:42:ac:12:00:03",
"IPv4Address": "172.18.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]

 

docker ps:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c2092fb2ed1a webapp:local "watchmedo auto-rest…" 2 seconds ago Up 1 second shoppa_web-test_1
951450e98f98 webapp:local "watchmedo auto-rest…" 3 seconds ago Up 2 seconds 0.0.0.0:8000->8000/tcp shoppa_webapp_1
7f9ffd39f6f1 userservice:local "watchmedo auto-rest…" 3 seconds ago Up 2 seconds shoppa_userservice-test_1
d4ac35e616a0 userservice:local "watchmedo auto-rest…" 4 seconds ago Up 4 seconds 0.0.0.0:8002->8002/tcp, 0.0.0.0:52496->52496/tcp shoppa_userservice_1
8f108ac443b2 postgres "docker-entrypoint.s…" 26 hours ago Up 4 seconds 0.0.0.0:8001->5432/tcp shoppa_db_1

Don't know where to find the debugger logs.

Any help is appreciated!

0
Comment actions Permalink

hey,

 

I uploaded the logs to the FTP server you mentioned:

logs-20190320-134134.zip

Also, please find a minimal example to repro here

 

edit: I also tried removing the network mode from the compose file, with no luck whatsoever

 

Cheers,

P

0
Comment actions Permalink

Thank you for the project, we've reproduced the issue and stumbled upon the following ticket: https://youtrack.jetbrains.com/issue/PY-32022

It boils down to the entrypoint defined in your Dockerfile. After I changed it to CMD instead of ENTRYPOINT, the debugger started to work. Please try it.

0
Comment actions Permalink

Solution worked fine. Thank you!

0

Please sign in to leave a comment.