Hi all, after few minutes of frustration I finally got the django debug toolbar showing in my django apps running in docker managed by docker-compose. This issue happened to me quite a few times now and it really pisses me off to not know why this is happening. And that was a really simple issue…
If you started to dockerize your django app, I am sure that you encountered some weird difficulties that you managed to fix after few google requests. There’s some though that you might have fixed without any explanation. That’s the problem I find in every response I found about how to solve this problem.
I have to admit maybe not everyone is developing inside a docker environment but still I am surprised that I am the first one looking for a proper answer… (Thoughts: Maybe I just searched really badly actually). Anyway!
Let’s be quick, here’s the fix:
Ok that was the ultra short answer and please don’t think I wrote that without thinking, it took me one hour to figure out this bloody line 👍 (At least I learnt some stuff about Go Templates :p)
Docker-compose hides a lot of stuff. Final point.
Seriously docker-compose hides quite a ton of stuff. What you might have
not noticed was that your application is located in a specific network
that docker-compose created for you. It will be named something like
my_project_default or something like that. So your app has a proper
network where it will receive a proper ip etc… However, how your
localhost will be able to access to this subnet?? Thanks to the bridge
function in docker, one interface will be created on your local machine
proxing all the traffic to the specific network. Example:
I am developing Gringotts at
the moment. I go inside the docker folder and run
This command will create a
docker_default network (because I ran the
command from the docker folder). We can check that by running
network ls. Now we can run
ip addr and we should see that a new
interface appeared on the local machine. In my case it looks like
The good interface will be your network_id (showed with
ls) prefixed by br_. And the IP displayed there is the one allocated
to your local machine to access to the bridge network of your
application. So now I explained that, I could have done the short answer
differently but anyway, the result is the same. So if you followed
everything I explained, you understood that when you’ll access to your
app you’ll not use the common localhost ip as 127.0.0.1 but the bridge
one 172.19.0.1 instead. So that’s why you could not see the django debug
Sur ce codez bien, Ciao!