Running Local Docker Images in Minikube: A Quick Guide

Minikube allows you to run a single-node Kubernetes cluster locally, making it ideal for testing and development. However, Kubernetes typically pulls images from remote registries, which can be cumbersome when working with local Docker images. This guide explores two efficient methods to use your local Docker images within a Minikube cluster.

Method 1: Load Local Docker Images into Minikube

If you’ve already built a Docker image locally, you can load it directly into Minikube:​

minikube image load <image_name>

For example:​

minikube image load myapp:v1

After loading the image, you can deploy it using Kubernetes manifests or kubectl.

Method 2: Build Docker Images Directly in Minikube

Alternatively, you can build Docker images directly within the Minikube environment:​

minikube image build -t <image_name> .

For example:​

minikube image build -t myapp:v1 .

This approach eliminates the need to load images manually and ensures compatibility with the Minikube cluster.​

Other common tips for debugging using Minikube

Port Forwarding to Access Your Application

To access your application running in Minikube, you can use port forwarding:​

kubectl port-forward deployment/myapp 8080:8080

This command forwards port 8080 on your local machine to port 8080 on the myapp deployment within Minikube. You can then access your application at http://localhost:8080

Access the Kubernetes Dashboard:

minikube dashboard

This command opens the Kubernetes Dashboard in your default web browser.​

Get Minikube’s IP Address:

minikube ip

This command returns the IP address of the Minikube cluster.​

Use Minikube’s Docker Daemon

eval $(minikube -p minikube docker-env)

This command sets your shell to use the Docker daemon inside Minikube, allowing you to build images directly within the cluster.