简体   繁体   English

kubectl运行本地docker image- ImagePullBackOff状态

[英]kubectl run local docker image- ImagePullBackOff status

i build the docker image on my local machine and trying to pull docker image using kubectl. 我在我的本地机器上构建了docker镜像,并试图使用kubectl拉出docker镜像。 but its not starting the docker container. 但它没有启动docker容器。

images starts with docker command. 图像以docker命令开头。

REPOSITORY                                            TAG                 IMAGE ID            CREATED             SIZE
tomcat9                                               latest              8b228ac6f19f        About an hour ago   111 MB

It stats with ImagePullBackOff massage. 它使用ImagePullBackOff按摩统计。

$ 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? 如何让kubectl运行此docker镜像?

Thanks 谢谢

I see from your comments bellow you are using Minikube locally. 我从你的评论中看到你在本地使用Minikube。

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 . Minikube在虚拟机内部运行,Docker在Minikube内运行,而在你机器上运行的Docker是两个独立的实例,因此无法访问相同的图像,但是你可以使用eval $(minikube docker-env)内的Docker链接到本地​​Docker eval $(minikube docker-env) ,你可以在这里阅读更多。

Also, you can get more information about why the ImagePullBackOff has happened by running kubectl describe pods tomcat9-511437148-sgkwp . 此外,您可以通过运行kubectl describe pods tomcat9-511437148-sgkwp获取有关ImagePullBackOff发生原因的更多信息。

I used this yaml file, now image is deployed on the cluster. 我使用了这个yaml文件,现在图像部署在集群上。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM