How to connect to the Docker host from inside a Docker container?
<p>As of Docker version <code>18.03</code>, you can use the <code>host.docker.internal</code> hostname to connect to your Docker host from inside a Docker container.</p>
<p>This works fine on Docker for Mac and Docker for Windows, but unfortunately, this is not was not supported on Linux until Docker <code>20.10.0</code>was released in December 2020.</p>
<p>Starting from version <code>20.10</code> , the Docker Engine now also supports communicating with the Docker host via <code>host.docker.internal</code> on Linux. Unfortunately, this won't work out of the box on Linux because you need to add the extra <code>— add-host</code>run flag:</p>
<pre>
--add-host=host.docker.internal:host-gateway</pre>
<p>This blog post demonstrates the issue on Linux using a simple example and also explains the configuration to make sure you have an identical behavior across Linux, Mac, and Windows.</p>
<p><a href="https://medium.com/@TimvanBaarsen/how-to-connect-to-the-docker-host-from-inside-a-docker-container-112b4c71bc66"><strong>Read More</strong></a></p>