Kubernetes cannot pull image from private docker image repository
For minikube to pull from your own local docker registry, the tag affects the pull policy. Per Images docs, pull policy is IfNotPresent
by default EXCEPT if
- you use
:latest
as the tag for the image to use - OR you omit the tag for the image to use.
In those cases the pull policy will effectively default to Always
, which will attempt to pull from docker hub. This will cause minikube to be unable to fetch local images that have no tag or "latest" tag.
Moral of the story is, don't rely on the default because it is too confusing :)
So always explicitly state the pull policy:
- when deploying into minikube the pull policy should be
IfNotPresent
orNever
for the local images - when deploying into a cloud host (like AWS), pull policy should be as for public images (see below)
- the pull policy should be
Always
for those public images that use a tag like "latest" or "stable" (because the image the tagpoints will change over time), andIfNotPresent
for tags thatalways point to the same image (to avoid fetching more thannecessary)
This means that if you avoid using tags like latest and stable etc, there is only one rule to follow:
- explicitly set the
imagePullPolicy
in your spec (or on the command line in the case of run) toIfNotPresent
, as this is will always look for it locally first, and go to public registry if it is not found locally, and this will work whether or not you are deploying into minikube or cloud.
The problem is with the image pull policy - you have set this to Always (the default setting). This means that the Docker deamon always tries to pull the image from the outer Docker registry - you want to use the local one instead.
Try to add --image-pull-policy=Never
when creating a deployment.
A good tutorial of using locally created images is here (it helped me):
https://kubernetes.io/docs/tutorials/hello-minikube/#create-a-docker-container-image
Because Minikube is VM not a your localhost.You try this code eval $(minikube docker-env)
https://kubernetes.io/docs/getting-started-guides/minikube/
- Open Terminal
eval $(minikube docker-env)
- docker build .
- kubectl create -f deployment.yaml
just valid this terminal.if closed terminal again open terminal and write eval $(minikube docker-env)
eval $(minikube docker-env)
this code build image in Minikube