Why is Kubectl looking for a local image on the Internet?

3/30/2020

Please see my images below:

enter image description here

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:

enter image description here

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?

-- w0051977
docker
kubernetes

2 Answers

3/30/2020

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.

-- Derek Lemon
Source: StackOverflow

3/30/2020

"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.

-- Enzo
Source: StackOverflow