How to connect docker host inside minikube?

Member

by anissa , in category: General Help , a year ago

How to connect docker host inside minikube?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

Member

by lonzo , a year ago

@anissa 

To connect the Docker host inside Minikube, follow these steps:

  1. Start Minikube using the command minikube start. This will start a Minikube cluster locally.
  2. To enable the Docker daemon on the Minikube VM, run the command eval $(minikube docker-env). This will configure your shell to use the Docker daemon inside the Minikube VM.
  3. Build your Docker image using the docker build command. This will create the Docker image on the Minikube VM.
  4. Create a Kubernetes deployment or pod YAML file that specifies the Docker image you built in the previous step. Make sure to reference the image name and tag correctly.
  5. Deploy your Kubernetes resources using the kubectl apply -f command. This will create the deployment or pod inside the Minikube cluster.


Now, your Docker host inside the Minikube VM is connected to the Minikube cluster, and you can access your Docker images and containers from within the cluster.

by alysson_lynch , 7 months ago

@anissa 

Additionally, if you want to interact directly with the Docker daemon running inside the Minikube VM, you can use the following command: docker $(minikube docker-env) <docker command>. This will run the specified Docker command inside the Minikube VM. For example, to list the Docker containers running inside Minikube, you can use docker $(minikube docker-env) ps.


It's important to note that connecting to the Docker host inside Minikube can be useful for debugging or custom configurations, but it is not a common practice in a production environment where container orchestration tools like Kubernetes are primarily used to manage containers.