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?
You can also run a Docker image from your own Docker file using the docker-compose command. With compose, you can configure your application's services and then you can start all services with a single command. For example, set up a docker-compose. yml like this in your repository root (where the Dockerfile is):
Docker is still a useful tool for building containers, and the images that result from running docker build can still run in your Kubernetes cluster.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With