Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions debug_toolbar/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ def show_toolbar_with_docker(request: HttpRequest) -> bool:

# Test: Docker
try:
host = getattr(settings, "DEBUG_TOOLBAR_CONFIG", {}).get(
"DOCKER_COMPOSE_SERVICE", "host.docker.internal"
)
# This is a hack for docker installations. It attempts to look
# up the IP address of the docker host.
# This is not guaranteed to work.
docker_ip = (
# Convert the last segment of the IP address to be .1
".".join(socket.gethostbyname("host.docker.internal").rsplit(".")[:-1])
+ ".1"
".".join(socket.gethostbyname(host).rsplit(".")[:-1]) + ".1"
)
if request.META.get("REMOTE_ADDR") == docker_ip:
return True
Expand Down
7 changes: 7 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ Toolbar options
This setting is a set of the full Python paths to each panel that you
want disabled (but still displayed) by default.

* ``DOCKER_COMPOSE_SERVICE``

Default: ``None``

If you use docker compose, besides the ``show_toolbar_with_docker`` you also
need to configure this setting to tell the name of the docker compose service.

* ``INSERT_BEFORE``

Default: ``'</body>'``
Expand Down