First I create a local Docker registry...
docker run -d -p 5000:5000 --restart=always --name registry registry:2
Then I push
docker push localhost:5000/jrg/hello-k8s
I confirm it is there by
$ docker pull localhost:5000/jrg/hello-k8s
Using default tag: latest
latest: Pulling from jrg/hello-k8s
Digest: sha256:c475cb7167208e8f018e54ad81d4b7bbbb9c14875bc1624bcce730edf9afede0
Status: Image is up to date for localhost:5000/jrg/hello-k8s:latest
Then I start Minikube
minikube start --insecure-registry=localhost:5000
But when I run
kubectl create deployment hello-k8s --image=localhost:5000/jrg/hello-k8s
I get
NAME READY STATUS RESTARTS AGE
hello-k8s-75846c4bfc-b7zp7 0/1 ErrImagePull 0 4s
What am I missing?
Update
I also tried (assuming 5.5.5.5 is the IP address for my wireless adapter (confirmed by accessing in the browser).
Then I start Minikube
minikube start --insecure-registry=5.5.5.5:5000
But when I run
kubectl create deployment hello-k8s --image=5.5.5.5:5000/jrg/hello-k8s
But I still get the same issue, also after a while it appears to become ImagePullBackOff
FYI Project (https://github.com/jrgleason/hello-kubernetes/tree/ADD_CASSANDRA)
If you are using minikube you must start the docker registry on the minikube machine. You can either use the minikube registry addon, or use docker yourself. Make sure to use the docker daemon from the minikube host:
eval $(minikube docker-env)
You must push the image to the right registry then, f.e. by using the remote docker daemon for building and pushing to 'localhost' (which is the minikube VM in that case)
I think the issue is localhost
will reference the kubernetes host itself, and not your registry.
You need to make it so that the registry is accessible from inside minikube. Try using the ip address of your computer instead of localhost
.
There is a proxy addon for minikube that will allow you to access localhost
from within minikube. I would suggest setting this up as the simplest solution https://github.com/Faithlife/minikube-registry-proxy
If this doesn't work there is a guide here to setup minikube with a local registry https://blog.hasura.io/sharing-a-local-registry-for-minikube-37c7240d0615/