2

I just move my Django app to use docker, but when I try to use the debugger, now it just disappears, not even a debug console log is outputted

debug disappear

I already add this following code to manage.py

    # Allow other computers to attach to ptvsd at this IP address and port.
    ptvsd.enable_attach(address=("localhost", 8001), redirect_output=True)
    # Pause the program until a remote debugger is attached
    ptvsd.wait_for_attach()

already opened the 8001 port for debugging in docker compose file

a-django-app:
    ....
    command: ./wait-for-it.sh postgis:5432 -s -- python3 manage.py runserver 0.0.0.0:8000 --enable-debugging
    ports:
      - "8000:8000"
      - "8001:8001"

Here's my launch .json config

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Attach (Docker)",
            "type": "python",
            "request": "attach",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}/",  
                    "remoteRoot": "/usr/src/ADjangoApp/"
                }
            ],
            "port": 8001,                   // Set to the remote port.
            "host": "localhost"        // Set to your remote host's public IP address.
        },
    ]
}

the flow of command:

  1. I run the app using docker-compose up
  2. I openned VSCode, and press the debugger button
  3. the debugger disappear
otong
  • 1,387
  • 2
  • 17
  • 28

0 Answers0