i build the docker image on my local machine and trying to pull docker image using kubectl. but its not starting the docker container.
images starts with docker command.
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat9 latest 8b228ac6f19f About an hour ago 111 MB
It stats with ImagePullBackOff massage.
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
tomcat9-511437148-sgkwp 0/1 ImagePullBackOff 0 9m
How can I make kubectl to run this docker image?
Thanks
I see from your comments bellow you are using Minikube locally.
Minikube runs inside a virtual machine, the Docker running inside Minikube and the Docker running on you machine are two separate instances so will not have access to the same images, you can however link the Docker inside Minikube to your local Docker using eval $(minikube docker-env)
, you can read more here.
Also, you can get more information about why the ImagePullBackOff
has happened by running kubectl describe pods tomcat9-511437148-sgkwp
.
I used this yaml file, now image is deployed on the cluster.
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tomcat9
labels:
app: tomcat9
spec:
template:
metadata:
labels:
app: tomcat9
spec:
containers:
- image: tomcat9:latest
name: tomcat9
imagePullPolicy: IfNotPresent
ports:
- name: http
containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: tomcat9
labels:
app: tomcat9
spec:
ports:
- nodePort: 30080
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: tomcat9
sessionAffinity: None
type: NodePort
status:
loadBalancer: {}