title: From inside of a Docker container, how do I connect to the localhost of the machine?
body: <p>So I have a Nginx running inside a docker container, I have a mysql running on the host system, I want to connect to the MySql from within my container. MySql is only binding to the localhost device.</p>
  <p>Is there any way to connect to this MySql or any other program on localhost from within this docker container?</p>
  <p>This question is different from &quot;How to get the IP address of the docker host from inside a docker container&quot; due to the fact that the IP address of the docker host could be the public IP or the private IP in the network which may or may not be reachable from within the docker container (I mean public IP if hosted at AWS or something). Even if you have the IP address of the docker host it does not mean you can connect to docker host from within the container given that IP address as your Docker network may be overlay, host, bridge, macvlan, none etc which restricts the reachability of that IP address.</p>