I am trying to run a docker image that I have build locally with Kubernetes.
Here is my command line:
kubectl run myImage --image=myImage --port 3030 --image-pull-policy=IfNotPresent
I have seen many peoples saying that we need to add the --image-pull-policy=IfNotPresent
flag so Kubernetes can look for the image locally instead of Docker Hub, but I still get this error (from the Minikube dashboard on the pod, the service and the deployment).
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'
But it looks like there is another issue here, I also tried --image-pull-policy=Never
and it doesn't work either.
Any idea?
The image
is not available in minikube
.
Minikube uses separate docker daemon
. That's why, even though the image exists in your machine, it is still missing inside minikube.
First, send the image to minikube by,
docker save myImage | (eval $(minikube docker-env) && docker load)
This command will save the image as tar archive, then loads the image in minikube by itself.
Next, use the image in your deployment with image-pull-policy
set to IfNotPresent
kubectl run myImage --image=myImage --port 3030 --image-pull-policy=IfNotPresent