I have setup docker on my machine and also minikube which have docker inside it, so probably i have two docker instances running on different VM
I build an image and
It is a popular question in the docker-land. See here. https://stackoverflow.com/a/24326540/6785908
There are other ways too, for example, For Docker on mac, docker.for.mac.localhost DNS name will resolve to the hostmachine
From https://docs.docker.com/docker-for-mac/networking/#i-cannot-ping-my-containers
The Mac has a changing IP address (or none if you have no network access). From 17.06 onwards our recommendation is to connect to the special Mac-only DNS name docker.for.mac.localhost which will resolve to the internal IP address used by the host.
Assuming that primary purpose of this minikube is for local testing, there is an easier way deploy your docker container (This doesnt even need a local docker registry)
First thing to understand here is, when you install docker in your machine, it has 2 parts, 1) a docker cli with which you can interact with docker daemon 2) A docker daemon. In this method we will point our local docker cli to minikube's docker daemon and execute docker build.
https://github.com/kubernetes/kubernetes.github.io/blob/master/docs/getting-started-guides/minikube.md#reusing-the-docker-daemon
quoting relevant parts here
When using a single VM of Kubernetes, it's really handy to reuse the minikube's built-in Docker daemon; as this means you don't have to build a docker registry on your host machine and push the image into it - you can just build inside the same docker daemon as minikube which speeds up local experiments. Just make sure you tag your Docker image with something other than 'latest' and use that tag while you pull the image. Otherwise, if you do not specify version of your image, it will be assumed as :latest, with pull image policy of Always correspondingly, which may eventually result in ErrImagePull as you may not have any versions of your Docker image out there in the default docker registry (usually DockerHub) yet.
To be able to work with the docker daemon on your mac/linux host use the docker-env command in your shell:
eval $(minikube docker-env)
You should now be able to use docker on the command line on your host mac/linux machine talking to the docker daemon inside the minikube VM:
do a docker container list command : docker ps. It should display even the containers related to kubernetes system (because now your cli is pointed to a docker daemon where your minikube is running).
Now build your docker image. Then it will be available in the minikube for you.