How to connect to mysql running on local mac from container

Using 1.12 on the mac

Created a network for some containers “docker network create mynet”

I have a few containers assigned to “mynet” that needs to connect to mysql running on my Mac (not in another container but the actual OS-X laptop) at 0.0.0.0:3306

I am not sure what “ip” my container needs to be given to tell it where to connect. The “mynet” gateway does not work (i.e.the gateway listed from “docker network inspect mynet”.

Also tried the actual IP of my mac (i.e. a 192.168.0.x ip)

I tried some approaches, and neither worked out.

The problem particularly with Mac Docker is that even the --net=host doesn’t work out of the box for your use case, since you would use the internal VMs network stack in your container, not your hosts.

I’m also interested in a solution.

As a temporary solution you could run mysql in a container, mounting /var/lib/mysql/ inside it.