kubectl run local docker image- ImagePullBackOff status

和自甴很熟 提交于 2019-12-06 07:48:29

问题


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


回答1:


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.




回答2:


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: {}    


来源:https://stackoverflow.com/questions/43462384/kubectl-run-local-docker-image-imagepullbackoff-status

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!