Skip to content

Debug Django Code With Docker Compose

Ismael edited this page Jan 9, 2017 · 1 revision

1. Docker Running!!

Start docker-compose

2. Retrieve all containers running in your computer

In another terminal use command: $ docker ps

And get the id of the Django container Containers list

Attach to the container

$ docker attach 9339824e2154

Now that terminal is attached to the docker container running django. If you perfor a request you will see the request log in that terminal.

Set the debug breakpoint

Using this line:

import ipdb;ipdb.set_trace()

set breakpoint

Make the request running through that code

And it will stop in the breakpoint:

Stopping in breakpoint

Navigate through the code is pretty easy.

Main commands:

h: help

n: next

s: step-in

u: step-up

c: continue

l: list context

Example:

ipdb help

Clone this wiki locally