How can I connect from a local Kubernetes to a DB on my local machine

1/1/2019

I'm using Docker Desktop for mac for Kubernetes in local desktop. I'm trying to connect to DB installed on my local machine within a pod but can't figure what should be the host address. How can I relate to the address of my machine within a pod?

Please note that I can't use the ip of my machine since the db port is blocked in my network.

-- Yaniv
docker
docker-desktop
docker-for-mac
kubernetes
macos

1 Answer

1/1/2019

From docker 18.03 onwards, you can use special DNS namehost.docker.internal which resolves to the internal address used by host.

Please look at the official docs here for more information on this.

If you're on earlier version than docker 18.03, you need to use the experimental DNS name docker.for.mac.localhost to resolve to the local host.

Hope this helps.

-- Prafull Ladha
Source: StackOverflow