Reputation: 21
I am trying to run a docker image that I have build locally with Kubernetes.
Getting below error
Failed to pull image "myImage": rpc error: code = Unknown desc = Error response from daemon: pull access denied for myImage, repository does not exist or may require 'docker login'
In yaml file i have given as
image: myImage
imagePullPolicy: IfNotPresent
In local i am using docker-desktop and minikube.
I have tried multiple ways but only thing is working on to make tar of myImage and load in minikube. I have tried using eval $(minikube docker-env) but after this my image is not able to build because it's pulling base image from organization nexus server. Can anyone suggest anyother way?
Upvotes: 1
Views: 1626
Reputation: 21
Maybe this is a little bit late but... if anyone has the same issue, here is how I solved something like this:
You need to pass "Never" as imagePullPolicy:
imagePullPolicy: Never
You need to load the image inside minikube:
minikube image load myImage
After all this, just continue as usual:
kubectl apply -f whereverTheFileIs.yaml
Upvotes: 1
Reputation: 11930
To fix this, set imagePullPolicy
to Never
.
Ensure to set eval $(minikube docker-env)
before building the image.
Upvotes: 1
Reputation: 133
Unfortunately I can't comment yet so I have to post an answer. The image you're trying to pull, myImage
does not exist in the local image cache of your kubernetes cluster. Running a docker image ls
command should yield a list of images that are available locally. If docker doesn't find an image locally, it will (by default) then go to Docker Hub to find the image. Seeing as the image listed has no prefix like someOrganization\
the image is assumed to be an officially published image from DockerHub themselves. Since your locally built image isn't an official Dockerhub image it doesn't know what to run. So the core of the problem is that your minikube doesn't have access to wherever you built your image. Unfortunately I haven't used minikube before so i'm unable to comment on any intricacies of how to work with it. I would be remiss if I left my answer like that, though, so looking at the docs for minikube ( REF: https://minikube.sigs.k8s.io/docs/handbook/pushing/#1-pushing-directly-to-the-in-cluster-docker-daemon-docker-env ) you're doing the right thing with the eval.
Sooo... your minikube isn't stock/vanilla and it pulls from a company repo? Sounds like you need to alter your minikube or you should re-evaluate the base image you're using and fix the Dockerfile.
Upvotes: 1