user2849678 user2849678 - 3 years ago 270
MySQL Question

How to connect to MySQL server on localhost from inside of a Docker container in a windows machine?

I have seen the other ticket on Linux. My issue is on Windows.

I want my Java code running inside a Container to connect to MySQL on

localhost
OR i.e.
127.0.0.1
.

I am able to connect to MySQL with either
localhost
or
127.0.0.1
, from the host, but not from within the container.

I've also tried the network option which is
--net="host"
.

Answer Source

You can use this hostname to connect from within a container to services running on the host: docker.for.win.localhost

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download