Docker Debugging Setup for Barodybroject¶
Quick Start¶
- Start containers:
docker-compose up -d - Open VS Code: Launch configuration "🐍 Python/Django Debug (Attach to Docker)"
- Set breakpoints in your Django code
- Navigate to http://localhost:8000 to trigger debugging
Components¶
🐳 Docker Configuration¶
- Port 8000: Django development server
- Port 5678: Debugpy debugging port
- Development entrypoint: Uses Django runserver with debugpy
🔧 VS Code Integration¶
- Attach Configuration: Connects to debugpy running in container
- Path Mapping: Maps
/app(container) to${workspaceFolder}/src(local) - Pre-launch Task: Automatically starts Docker containers
📁 Files Modified¶
docker-compose.yml: Development configuration with debug portssrc/entrypoint-dev.sh: Development entrypoint with debugpysrc/requirements.txt: Added debugpy dependency.vscode/launch.json: Updated with attach configuration.vscode/tasks.json: Fixed Docker task paths
🚀 Available Launch Configurations¶
- 🐍 Python/Django Debug (Attach to Docker) (Recommended)
- Attaches to running Django container with debugpy
- Full debugging capabilities with breakpoints
-
Automatic Docker container startup
-
🐍 Python/Django in Docker (Launch)
- Alternative direct launch method
- Runs Django locally (outside container)
🛠 Available Tasks¶
- Django: Start Debug Server: Starts Django with debugpy waiting for VS Code
- Django: Run Development Server (Debug Ready): Starts Django ready for debugging
- Django: Run Migrations: Database migrations in Docker
- Django: Create Superuser: Create admin user in Docker
- Django: Collect Static Files: Static file collection in Docker
Troubleshooting¶
Container Won't Start¶
# Check container status
docker-compose ps
# View container logs
docker-compose logs web
# Rebuild if needed
docker-compose build --no-cache
Debugging Not Working¶
- Ensure containers are running:
docker-compose ps - Check debugpy port is exposed:
docker-compose logs web | grep 5678 - Verify VS Code is using correct launch configuration
- Check path mappings in launch.json
Django Issues¶
- Database connection: Ensure PostgreSQL container is healthy
- Static files: Run "Django: Collect Static Files" task
- Migrations: Run "Django: Run Migrations" task
Production vs Development¶
Development (docker-compose.yml)¶
- Uses
entrypoint-dev.sh - Django development server on port 8000
- Debugpy enabled on port 5678
- DEBUG=True
Production (docker-compose.prod.yml)¶
- Uses
entrypoint.sh - Gunicorn server on port 80
- No debug ports
- DEBUG=False
Status: ✅ Docker debugging fully configured and ready Last Updated: October 26, 2025