Debugging
Backend Debugging (Django Webserver)
Attaching to the Container
- Find the container ID:
docker ps
Look for the container named backend-dev and note its ID.
- Attach to the container:
docker attach <container_id>
Using ipdb for Debugging
- Add breakpoints in your code:
import ipdb; ipdb.set_trace()
-
When the breakpoint is hit, you'll enter the ipdb debugger.
-
Use ipdb commands to debug. Common commands:
- n: Next line
- c: Continue execution
- p variable: Print variable
For more commands, refer to the ipdb cheatsheet
Exiting the Debugger
To detach from the container without stopping it:
- Press Ctrl + P, then Ctrl + Q
This sequence allows you to exit while leaving the container running.