Call / Connect to Host Machine from a Docker Container

fred @ Veröffentlicht am

When running a Docker container in some isolated environment (e.g. for testing purposes), one thing you often want to do is to call a service located in some other container running on your host system.

Without some sort of service discovery these are invisible to the container itself. What you need in this case is the IP address of the host system so that it can be reached from within the container. I myself recently had that problem when I locally needed to test how two services directly interact with one another.

Googling the issue I found out that it is highly sought after although the solution is stunningly simple. Get a list of your network interfaces in the shell of your choice:

1
2
3
ipconfig // on windows
iwconfig // linux
ifconfig // linux

The output should be somewhat similar to what you’re seeing in the picture above. Try to track down the docker network interdace et voila: here’s the IP you were looking for.

That being said: On Windows it’s most probably always 10.0.75.1.

Veröffentlicht am

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.

*

*