How to access the minikube from a docker container?

by emerald.wunsch , in category: General Help , 3 months ago

How to access the minikube from a docker container?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by lia , 3 months ago

@emerald.wunsch 

To access minikube from a Docker container, you need to use the host.docker.internal DNS name, which resolves to the IP address of the host machine.


Here are the steps to access minikube from a Docker container:

  1. Make sure minikube is running on your host machine. You can start it by running minikube start.
  2. Build your Docker image using the Dockerfile and any necessary dependencies.
  3. Run a Docker container based on the image you built, and make sure to expose the ports that you need to access minikube. docker run -it -p 8080:8080 -p 8443:8443 --name my-container
  4. In your container, you can now access minikube using the host.docker.internal DNS name. For example, if your minikube setup exposes a service on port 8080, you can access it from within your container using http://host.docker.internal:8080.


Note: The host.docker.internal DNS name is only supported on Docker Desktop for Mac (v18.03+) and Docker Desktop for Windows (v18.06+), so make sure you are using a compatible version.