When using the bridge network, on Windows and Mac, host.docker.internal
can be resolved from inside the container, and it seems that it can be connected to the host PC.
However, for some reason Linux does not have that feature as of 20200310. There is a sign that it will be possible soon, but ...
Until then, this method seems to be enough to pass the host IP when launching the container.
docker run -it --add-host=host.docker.internal:$(ip route | grep docker0 | awk '{print $9}') debian bash
Recommended Posts