How do I get a locally built docker image into minikube with the least amount of pain, and the greatest amount of speed?
If you’re developing with minikube, you’d frequently need to get docker images you build locally inside minikube so that your kubernetes deployments etc. work well.
eval $(minikube docker-env) and use docker to build images. Docker images will be built inside (and will hence be available inside) minikube.
In an earlier guide, https://hasura.io/blog/sharing-a-local-registry-for-minikube-37c7240d0615 I talked about how you can run a local registry on minikube and integrate your normal docker workflow with it.
Pros of running docker-registry inside minikube: Docker images are built outside minikube (on your local filesystem, or inside docker-machine)
Cons of running docker-registry inside minikube: You need to setup atleast one port-forward and keep it running, and 2 if you’re on a non-linux system
There is an alternative approach of getting your files inside minikube without having to run a local registry at all.
Instead of building images outside minikube and then getting them inside minikube:
docker build some-image #this happens on your local docker docker push minikube/some-image #you push the image to minikube
docker build some-image #this is happening inside minikube!
Point your docker client to run against the docker-daemon inside minikube:
Once you’ve created a minikube cluster with
minikube start. This is a one-liner:
$> eval $(minikube docker-env)
And that’s it. Your local docker is now using the docker daemon inside minikube.
$> docker build -t my-image . #Build a docker image locally $> minikube ssh $> docker images my-image #You'll see the docker image here
Quick and dirty:
eval $(minikube docker-env)
The longer way, safer if you’re re-creating minikube clusters often: https://hasura.io/blog/sharing-a-local-registry-for-minikube-37c7240d0615#47b3