How do I reach a containerized django web app running in visual studio code debug mode?

After some path changes due to being a git submodule, I was able to configure a launch.json and tasks.json to get my application running in debug mode. Here are the tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "docker-build",
            "label": "docker-build",
            "platform": "python",
            "dockerBuild": {
                "tag": "signmeasures:latest",
                "dockerfile": "${workspaceFolder}/signmeasures-frontend/Dockerfile",
                "context": "${workspaceFolder}",
                "pull": true
            }
        },
        {
            "type": "docker-run",
            "label": "docker-run: debug",
            "dependsOn": [
                "docker-build"
            ],
            "python": {
                "args": [
                    "runserver",
                    "0.0.0.0:8000",
                    "--nothreading",
                    "--noreload"
                ],
                "file": "signmeasures-frontend/signmeasures/manage.py"
            }
        }
    ]
}

and here is the launch.json

{
    "configurations": [
        {
            "name": "Docker: Python - Django",
            "type": "docker",
            "request": "launch",
            "preLaunchTask": "docker-run: debug",
            "python": {
                "pathMappings": [
                    {
                        "localRoot": "${workspaceFolder}/signmeasures-frontend",
                        "remoteRoot": "/app"
                    }
                ],
                "projectType": "django",
                "port": 5678,
                "host": "localhost"
            },
        }
    ]
}

I'm not too familiar with setting up the debug container or docker in general, I'm still trying to learn. When I hit the debug button on the debug tab, it builds a container and then in the debug console I see this

debug console

but when I try to go to localhost:8000 it does not load the web app. It shows this:

can't reach web app

I'm not sure what I need to change to be able to reach it and set breakpoints to debug this application. What should I do to be able to reach it and debug?

Back to Top