【K8S】pod无限重启,报错Back-off restarting failed container

1. 问题

pod启动后一直重启,并报Back-off restarting failed container。

原理: Back-off restarting failed container的Warning事件,一般是由于通过指定的镜像启动容器后,容器内部没有常驻进程,导致容器启动成功后即退出,从而进行了持续的重启。

2. 解决方案

**解决方法:**找到对应的deployment,加上如下语句: command: ["/bin/bash", "-ce", "tail -f /dev/null"]

python 复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
  name: test-file
  namespace: model
  labels:
    appkey: test-file
spec:
  replicas: 1
  selector:
    matchLabels:
      appkey: test-file
  template:
    metadata:
      labels:
        appkey: test-file
    spec:
      containers:
        - name: test-file
          image: xxx:v1
          command: ["/bin/bash", "-ce", "tail -f /dev/null"]
          imagePullPolicy: IfNotPresent
          volumeMounts:
          - name: test-file-data
            mountPath: /mnt
      volumes:
        - name: test-file-data
          hostPath: 
            path: /mnt
相关推荐
没有名字的小羊1 小时前
8.Docker镜像讲解
运维·docker·容器·tomcat
木鱼时刻1 小时前
容器与 Kubernetes 基本概念与架构
容器·架构·kubernetes
LCG元3 小时前
云原生微服务间的异步消息通信:最终一致性与系统容错的架构实战
微服务·云原生·架构
做一个AC梦4 小时前
Docker安装失败:Docker Desktop installation failed
运维·docker·容器
Shan12054 小时前
浅谈Docker Kicks in的应用
运维·docker·容器
Li&&Tao4 小时前
docker 常用命令
docker·容器·eureka
chuanauc12 小时前
Kubernets K8s 学习
java·学习·kubernetes
小张是铁粉12 小时前
docker学习二天之镜像操作与容器操作
学习·docker·容器
烟雨书信12 小时前
Docker文件操作、数据卷、挂载
运维·docker·容器
AnsonNie12 小时前
虚拟机与容器技术详解:VM、LXC、LXD与Docker
运维·docker·容器