Skip to main content

Debugging

Backend Debugging (Django Webserver)

Attaching to the Container

  1. Find the container ID:
docker ps

Look for the container named backend-dev and note its ID.

  1. Attach to the container:
docker attach <container_id>

Using ipdb for Debugging

  1. Add breakpoints in your code:
import ipdb; ipdb.set_trace()
  1. When the breakpoint is hit, you'll enter the ipdb debugger.

  2. 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.