VS code is not showing variables and breakpoint on debugging python inside container

Hellow I am using docker-compose to run a python file here is the dockerfile

FROM python:3.6.5 as base
ARG build_env=primary

RUN pip3 install --upgrade pip

COPY requirements.txt /
RUN pip3 install -r requirements.txt

WORKDIR /code
COPY / /code

# FROM base as debugger
RUN pip3 install ptvsd
CMD python -m  ptvsd --host 0.0.0.0 --port 5678 --wait --multiprocess test_xxx_worker.py

and here is the docker-compose

  stance_worker:
    build:  
      context: ./workers/xxx_worker
      dockerfile: Dockerfile
      args:
        target: debugger
    volumes:
     - ./workers/xxx_worker:/code    
    restart: always
    links:
     - redis
    ports: 
     - 5678:5678

and here is the lunch.json file

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Docker: xxx denugger ",
            "type": "python",
            "request": "attach",
            "host": "127.0.0.1",
            "port": 5678,
            "pathMappings": [
                {
                  "localRoot": "${workspaceFolder}/workers/xxx_worker/",
                  "remoteRoot": "/code"
                }
            ]
   
        },
      
    ]
}

Unfortunately the variables, watch and breakpoint are still not working
enter image description here

Source: Docker Questions

LEAVE A COMMENT