Debugging Django/Docker environment with VS Code

Im trying to setup VSCode Debugger for a docker/django environment but struggling

im busy following this guide
https://gist.github.com/veuncent/1e7fcfe891883dfc52516443a008cfcb

which worked on a different project, but i can’t seem to find out why it isn’t connecting to my breakpoints in this project. I have opened the ports in docker-compose and everything :/

django:
    build: .
    command: /start-dev.sh
    environment:
      - DJANGO_SETTINGS_MODULE=project.settings_docker
    volumes:
      - ./src:/code
    ports:
      - 8000:8000
      - 3000:3000
    depends_on:
      - mysql

Dockerfile looks something like this

RUN mkdir /code
WORKDIR /code

RUN pip install --upgrade pip
COPY ./requirements /requirements
RUN pip install --no-cache-dir -r /requirements/base.txt 
    && rm -rf /requirements

ADD ./src /code/

in VS my launch file looks as follows

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Django App",
            "type": "python",
            "request": "attach",
            "pathMappings": [
                {
                    "localRoot": "/Users/{USER}/workspace/{THEAPP}",
                    "remoteRoot": "/code/"
                }
            ],
            "port": 3000,
            "host": "localhost"
        }
    ]
}

The Start-dev.sh that runs the server

#!/bin/sh
python3 manage.py migrate --noinput
python3 manage.py runserver 0.0.0.0:8000

If i run this ever now and then i do receive an error message in my console saying.

pydev debugger: unable to find translation for: "/Users/{USER}/workspace/{THEAPP}/src/app/models.py" in ["workspace/{THEAPP}"] (please revise your path mappings).

In the launch.json file for VS i have added the full path to the app, if i use ${workspace} it doesn’t even give the error above.

if i run docker port {docker_container} i get

8000/tcp -> 0.0.0.0:8000
3000/tcp -> 0.0.0.0:3000

I also receive the print statement in manage.py saying that the debugger has been attached.

i replaced the sensitive information with {} tags for the question

Source: StackOverflow