Kubectl run local docker image - ImagePullBackOff status
I am creating a docker image on my local machine and trying to pull the docker image using kubectl. but doesn't start the docker container.
images start with docker command.
REPOSITORY TAG IMAGE ID CREATED SIZE
tomcat9 latest 8b228ac6f19f About an hour ago 111 MB
It is set using the ImagePullBackOff massage.
$ kubectl get pods
NAME READY STATUS RESTARTS AGE
tomcat9-511437148-sgkwp 0/1 ImagePullBackOff 0 9m
How can I make kubectl run this docker image?
thank
source to share
I can see from your comments that you are using Minikube locally.
Minikube runs inside a virtual machine, Docker running inside Minikube and Docker running inside your machine are two separate instances, so it won't have access to the same images, however you can link Docker inside Minikube to local Docker using eval $(minikube docker-env)
, you can read here .
Also, you can get more information about why this happened ImagePullBackOff
by running kubectl describe pods tomcat9-511437148-sgkwp
.
source to share
I used this yaml file, now the image is deployed to 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: {}
source to share