Minikube can't pull image from local registry

11.8k Views Asked by At

I ran eval $(minikube docker-env) then built a docker container. When I run docker images on my host I can see the image. When I run minikube ssh then docker images I can see it.

When I try to run it, the pod fails to launch. kubectl describe pod gives:

14m     3m      7   kubelet, minikube   spec.containers{quoting-crab-customer-refresh-cache-cron}   Normal      Pulling         pulling image "personalisation-customer:latest"
14m     3m      7   kubelet, minikube   spec.containers{quoting-crab-customer-refresh-cache-cron}   Warning     Failed          Failed to pull image "personalisation-customer:latest": rpc error: code = 2 desc = Error: image library/personalisation-customer:latest not found
14m     2s      66  kubelet, minikube                                   Warning     FailedSync      Error syncing pod
14m     2s      59  kubelet, minikube   spec.containers{quoting-crab-customer-refresh-cache-cron}   Normal      BackOff         Back-off pulling image "personalisation-customer:latest"

My imagePullPolicy is Always.

What could be causing this? Other pods are working locally.

5

There are 5 best solutions below

1
On BEST ANSWER

You aren't exactly pulling from your local registry, you are using your previously downloaded images or your locally builded, since you are specifying imagePullPolicy: Always this will always try to pull it from the registry.

Your image doesn't contain a specific docker registry personalisation-customer:latest for what docker will understand index.docker.io/personalisation-customer:latest and this is an image that doesn't exist in the public docker registry.

So you have 2 options imagePullPolicy: IfNotPresent or to upload the image to some registry.

0
On

The local Docker cache isn't a registry. Kubernetes tries to download the image from Dockerhub (the default registry), since you set iMagePullPolicy to Always. Set it to Never, so Kubernetes uses to local image.

0
On

I had the same issue. Issue was not mentioning the image version. I used

kubectl run testapp1 --image=<image> --image-pull-policy=IfNotPresent

instead of,

kubectl run testapp1 --image=<image>:<version> --image-pull-policy=IfNotPresent
0
On

You can ssh to minikube using ssh

minikube ssh -p <profilename>

and then pull the image

docker pull <image>

Make sure the imagePullPolicy: IfNotPresent

and then run your deployment

0
On

For minikube, make the changes as follows:

  1. Eval the docker env using: eval $(minikube docker-env)

  2. Build the docker image: docket build -t my-image

  3. Set the image name as only "my-image" in pod specification in your yaml file.

  4. Set the imagePullPolicy to Never in you yaml file. Here is the example:

    apiVersion:
    kind:
    metadata:
    spec:
      template:
         metadata:
            labels:
               app: my-image
      spec:
         containers:
           - name: my-image
           image: "my-image"
           imagePullPolicy: Never