【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
相关推荐
程序员酥皮蛋10 小时前
docker基础
docker·容器·eureka
没有退路那我就不要散步13 小时前
kube-proxy优化
docker·容器·kubernetes
阿狸猿15 小时前
论基于云原生数据库的企业信息系统架构设计
数据库·云原生
丑过三八线16 小时前
Kubernetes 常用命令速查手册
云原生·容器·kubernetes
bloglin9999916 小时前
docker镜像构建及部署样例
运维·docker·容器
SLD_Allen16 小时前
基于docker搭建sub2api图文教程
运维·docker·容器
睡不醒男孩03082318 小时前
云原生环境下的云成本优化(FinOps)落地全景指南
云原生·clup
木雷坞19 小时前
LiteLLM Docker 部署:config.yaml、Master Key 和 Postgres 配置
运维·docker·容器·litellm
川石课堂软件测试19 小时前
UI自动化测试|元素操作&浏览器操作实践
功能测试·测试工具·mysql·ui·docker·容器·单元测试
丑过三八线19 小时前
Docker Podman 启动命令
docker·容器·podman