Please see my images below:
I then run this:
kubectl run my-app --image=iansimage:latest --port=5000
and this:
kubectl expose deployment my-app --type=LoadBalancer --port=8080 --target-port=5000
However, I then see this:
Notice the warning in the above screenshot: "Error response from daemon: pull access denied for iansimage, repository does not exist or may require 'docker login': denied: requested access to the resource is denied".
Why is Kubectl trying to find iansimage:latest on the internet? iansimage:latest is a local image I created as per my last question: Create an image from a Dockerfile
Please note that I am new to Kubernetes so this may be simple?
Update
Following on from Burak Serdars's comment. Say I have a com,and like this, which would nomally build an image: docker build -t "app:latest" .
How would I build this image inside a Kubernetes pod?
When you use kubectl run I believe it will create a deployment resource with a member named ImagePullPolicy which I believe defaults to Always
. You might be able to change this with kubectl edit deployment my-app
to set this field to IfNotPresent
.
You might also consider @Enzo's suggestion to tag the image to a particular version.
"Latest" is a special tag, it means that Docker always check if the downloaded image is the latest available searching the registry. Retag your image with other tag than latest, like this :
docker tag iansimage:latest iansimage:v1
Then change your Yaml and use iansimage:v1
That solve your problem.