I\'ve just registered for this question. It\'s about if it\'s possible to remote debug python code in a Docker Container with VS Code. I am having a completely configured Docker
works with vscode 1.45.0 & later. for reference files https://gist.github.com/kerbrose/e646aaf9daece42b46091e2ca0eb55d0
1- Edit your docker.dev
file & insert RUN pip3 install -U debugpy
. this will install a python package debugpy
instead of the deprecated one ptvsd
because your vscode (local) will be communicating to debugpy
(remote) server of your docker image using it.
2- Start your containers. however you will be starting the python package that you just installed debugpy
. it could be as next command from your shell.
docker-compose run --rm -p 8888:3001 -p 8879:8069 {DOCKER IMAGE[:TAG|@DIGEST]} /usr/bin/python3 -m debugpy --listen 0.0.0.0:3001 /usr/bin/odoo --db_user=odoo --db_host=db --db_password=odoo
3- Prepare your launcher file as following. please note that port
will be related to odoo server. debugServer
will be the port for the debug server
{
"name": "Odoo: Attach",
"type": "python",
"request": "attach",
"port": 8879,
"debugServer": 8888,
"host": "localhost",
"pathMappings": [
{
"localRoot": "${workspaceFolder}",
"remoteRoot": "/mnt/extra-addons",
}
],
"logToFile": true