Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running local docker image in Minikube

I have set up Docker for Windows and minikube. Example listed here for (k8s.gcr.io/echoserver:1.10) works just fine: https://kubernetes.io/docs/setup/learning-environment/minikube/.

However when I create simple .NET MVC app under c:\dev\helloworld and try to run in in Minikube I get status: CrashLoopBackOff

Environment: Windows 10 Enterprise

Please help. What do i need to set up to make this work? u

like image 797
ShaneKm Avatar asked Sep 03 '19 19:09

ShaneKm


1 Answers

If you target the Docker daemon running in the minikube VM when you run docker build instead of the Docker for Windows daemon running on the host, then the minikube Docker will have access to that image and subsequent kubectl run commands will work as desired. I'm not sure exactly which commands to run on Windows, but on a POSIX system like Macs or Linux you can run:

# make 'docker' commands use daemon in minikube
eval $(minikube docker-env)

# build image so that minikube Docker daemon has it
docker build -t hello-world:v1 .

# deploy to kubernetes
kubectl run hello-world --image=hello-world:v1 --port=8080

# unset DOCKER environment variables so it goes back to 
# targetting the usual Docker for Windows
eval $(minikube docker-env -u)

I don't know if eval is the right thing to run on Windows, but if you just run minikube docker-env it will likely give you some instructions, e.g. for me it gives:

$ minikube docker-env
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.103:2376"
export DOCKER_CERT_PATH="/Users/amitgupta/.minikube/certs"
# Run this command to configure your shell:
# eval $(minikube docker-env)
like image 111
Amit Kumar Gupta Avatar answered Oct 22 '22 21:10

Amit Kumar Gupta