Simplify Docker IP determination in middleware.py #2098
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Updated
show_toolbar
function indebug_toolbar/middleware.py
to usegateway.docker.internal
for Docker IP determination per @srus's comment.To test in a multicontainer, production-ready environment, a cookiecutter-django template configured for Docker was used.
After starting an interactive shell inside the Django container, the commands below were run to compare our current implementation (
host.docker.internal
) to the proposed change to (gateway.docker.internal
).This confirms that since
host.docker.internal
resolves to 192.168.65.254, we don’t need to modify the last octet manually. Instead, we can directly usegateway.docker.internal
, which already resolves to 192.168.65.1.The warning in our docs at installation is still valid.
Tested on:
Keeping as a draft PR until we have tested in at least one more Docker version as well as Podman per @matthiask 's comment.
Fixes #2076
Checklist:
docs/changes.rst
.