【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
相关推荐
探索云原生8 小时前
Kubernetes 官方出品:一个 Controller 搞定 Job 排队和资源配额
ai·云原生·kubernetes·scheduler
BullSmall10 小时前
Sonarqube9.9 docker 镜像启动后 conf 下的配置文件没有了
docker·容器·eureka
spider_xcxc11 小时前
Docker 实战:容器化多服务应用,Dockerfile 与 Compose 配置全解析
docker·云原生·eureka·虚拟化·容器化
hay_lee12 小时前
Kubernetes StatefulSet:OrderedReady 极简指南
云原生·容器·kubernetes
晚风吹长发12 小时前
Docker使用——Docker容器及相关命令
linux·运维·服务器·docker·容器·架构
ShiXZ21312 小时前
Docker Compose 安装与配置指南
运维·docker·容器
BullSmall13 小时前
Anolis OS 8.10 Docker 部署 SonarQube 9.9 完整教程
运维·docker·容器
人间凡尔赛14 小时前
AI-Native 云原生架构:2026 年从容器编排到智能体编排的范式革命
后端·云原生·架构
成为你的宁宁14 小时前
【K8s HPA 水平扩缩容】
kubernetes·hpa
欢醉14 小时前
k8s调度容器失败The node had condition: [DiskPressure]
kubernetes·springcloud