When working with Kubernetes locally using Minikube, you may want to use a Docker image you built on your machine—without pushing it to a remote registry like Docker Hub.
Fortunately, Minikube makes it easy to use local Docker images directly inside your Kubernetes cluster, but it does require one extra step: building the image inside Minikube’s Docker environment.
In this post, you’ll learn how to:
- Build and use local Docker images with Minikube
- Avoid pushing to external registries
- Test Kubernetes deployments faster in a local development loop
💡 The Problem
If you build an image on your host:
docker build -t my-app:latest .
Then try to use it in a Minikube deployment:
image: my-app:latest
You’ll likely see ImagePullBackOff or ErrImagePull, because the Minikube cluster can’t see your host’s Docker daemon or images.
✅ Solution: Build Inside Minikube’s Docker Daemon
Minikube runs its own lightweight VM or container with a separate Docker daemon. To make an image accessible to Minikube, you need to build it inside that Docker environment.
Step 1: Point Docker CLI to Minikube’s Docker daemon
Run:
eval $(minikube docker-env)
This temporarily reconfigures your shell to use Minikube’s Docker daemon.
Step 2: Build the Docker image
Now build the image like normal:
docker build -t my-app:latest .
This time, the image will be created inside Minikube, making it instantly available to your cluster.
Step 3: Use the image in your Kubernetes deployment
In your YAML file (e.g. deployment.yaml
):
containers:
- name: my-app
image: my-app:latest
Now, when you deploy:
kubectl apply -f deployment.yaml
Minikube will use the locally built image without needing to pull from a registry.
🧼 Reset Docker Environment
When you’re done and want to return to using your host Docker CLI, run:
eval $(minikube docker-env -u)
🔄 Bonus: Automate with Skaffold
If you want to build-and-deploy workflows more efficiently, try using Skaffold with Minikube. It handles building local images and deploying to Minikube automatically.
❓ Alternative: Load Image Using minikube image load
If you already built the image on your host and want to import it into Minikube, run:
minikube image load my-app:latest
This command transfers the image from your host to Minikube’s Docker environment—useful if you don’t want to switch Docker contexts.
📝 Conclusion
Minikube is a powerful tool for local Kubernetes development, and you don’t need a remote registry to test your Docker images. By using Minikube’s Docker daemon or minikube image load
, you can iterate quickly and deploy local changes without leaving your development machine.
🔑 Summary
Task | Command |
---|---|
Use Minikube’s Docker daemon | eval $(minikube docker-env) |
Build inside Minikube | docker build -t my-app:latest . |
Revert to host Docker daemon | eval $(minikube docker-env -u) |
Load host image into Minikube | minikube image load my-app:latest |