【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
相关推荐
AscendKing8 分钟前
在 CentOS 系统上安装 Docker
云原生·安装 docker·centosdocker
JavaLearnerZGQ2 小时前
Docker部署Nacos
数据库·docker·容器
derek20265 小时前
什么是云原生?
云原生
LCY1335 小时前
阿里云上进行k8s集群的配置
阿里云·kubernetes·云计算
蓝天居士5 小时前
docker常用命令集(6)
docker·容器
Serverless社区5 小时前
五年磨一剑:Agent 时代追风不如造风
阿里云·云原生·serverless·函数计算
巴厘猫5 小时前
从零解锁Docker API,玩转容器的“幕后英雄”!
后端·docker·容器
阿里云云原生6 小时前
活动邀请 | 阿里云AI原生应用开发实战营—Serverless AI 专场(北京站)开启报名!
云原生·serverless
阿里云云原生6 小时前
AI Gateway 分析:OpenRouter vs Higress
微服务·云原生
●VON6 小时前
重生之我在暑假学习微服务第五天《Docker部署项目篇》
java·学习·docker·微服务·云原生·架构·暑假