Fix adding host ip to INTERNAL_IPS when using Docker

The ip returned by `socket.gethostname()` is default docker `172.21.0.1` ip, which is not the actual IP of the host. Replace `socket.gethostname()` with `host.docker.internal`.
This commit is contained in:
David Păcioianu 2024-04-08 14:28:36 +03:00 committed by GitHub
parent 681c13e0fa
commit c50ca2bf3f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -73,7 +73,7 @@ INTERNAL_IPS = ["127.0.0.1", "10.0.2.2"]
if env("USE_DOCKER") == "yes":
import socket
hostname, _, ips = socket.gethostbyname_ex(socket.gethostname())
hostname, _, ips = socket.gethostbyname_ex("host.docker.internal")
INTERNAL_IPS += [".".join(ip.split(".")[:-1] + ["1"]) for ip in ips]
{%- if cookiecutter.frontend_pipeline in ['Gulp', 'Webpack'] %}
try: