Debugging in Docker with VS Code(Odoo 18)
- John Julius Danker Khoo
- Jun 2
- 2 min read
Building upon from a previous post [How to Set up Odoo CE 18 Docker Desktop (Windows OS)]
Debugging Python apps inside Docker containers can be difficult. This guide shows how to live debug Odoo using debugpy, Docker, and VS Code making your dev cycle faster and more efficient. This guide focuses on debugging custom modules in Odoo 18, assuming your environment is already set up as per the referenced Docker guide
Benefits
Real-time debugging with breakpoints.
Seamless local-to-container code mapping.
Inspect and trace live code.
Reviewed steps on live debugging with docker
Launch.json
{   "version": "0.2.0",   "configurations": [       {           "name": "Odoo Docker Debugger",           "type": "debugpy",           "request": "attach",           "debugServer": 5678, // The port that the debugger will listen on           "pathMappings": [               {                   "localRoot": "${workspaceFolder}/custom/addons",                   "remoteRoot": "/mnt/extra-addons"               }           ]       }   ] } |
Docker-compose.yml
 Odoo:     container_name: odoo     build: .      Ports:       - "5678:5678" # debugpy port     environment:       - DEBUGPY_PORT=5678 # Port for debugpy       - APP_ENV=debug |
Dockerfile
# Copy custom addons COPY ./custom/addons /mnt/extra-addons # Copy entrypoint script and Odoo configuration file COPY ./entrypoint.sh / RUN chmod +x /entrypoint.sh # Make entrypoint.sh executable # Entrypoint ENTRYPOINT ["/entrypoint.sh"] |
case "$1" in     -- | odoo)         shift         if [[ "$1" == "scaffold" ]]; then             exec odoo "$@"         else             wait-for-psql.py "${DB_ARGS[@]}" --timeout=90             # Replace Odoo execution with debugpy             exec python3 -m debugpy --listen 0.0.0.0:5678 /usr/bin/odoo "$@" "${DB_ARGS[@]}"         fi         ;;     -*)         wait-for-psql.py "${DB_ARGS[@]}" --timeout=90         exec python3 -m debugpy --listen 0.0.0.0:5678 /usr/bin/odoo "$@" "${DB_ARGS[@]}"         ;;     *)         exec "$@" esac |
Requirements.txt
debugpy psycopg2-binary |
Run docker-compose up
Set breakpoint in VS Code Custom addons folder
Run Odoo Debug

Docker enter localhost environment
Test hitting breakpoint
