【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
相关推荐
pride.li4 小时前
Docker教程-Docker安装与镜像配置
运维·docker·容器
bgy66664 小时前
Docker Swarm 容器编排实战指南
运维·docker·容器
再卷还是菜5 小时前
Cephfs总结及kubernetes+Cephfs的整合项目
云原生·容器·kubernetes
底层玩家老张5 小时前
数据库上K8s,运维为什么反而更累了?从StatefulSet到Operator的复盘
数据库·kubernetes·operator·数据库运维·架构选型
力江6 小时前
GitLab 私有化部署实战 —— 从 Omnibus 到 Docker 的踩坑之旅
docker·容器·gitlab
深念Y6 小时前
Docker 镜像体积从 110MB 降到 13MB 后端服务的瘦身
运维·docker·容器
秦jh_8 小时前
【Docker】镜像仓库
docker·容器
IT大白鼠8 小时前
使用 Docker 部署 Kubernetes 集群:容器方式搭建 K8s 环境
docker·容器·kubernetes
大大大大晴天️11 小时前
从 HDFS 到对象存储:计算存储分离如何重塑云原生大数据底座
大数据·云原生