k8s pod无限重启 报错Back-off restarting failed container

现象

K8S POD无限重启
报错Back-off restarting failed container

原因

由于启动容器后,容器内部没有常驻的前台进程,导致容器启动成功后即退出,从而进行了持续的重启。
例如ubuntu这类操作系统容器,nginx这种默认后台执行的容器

解决

  • 操作系统容器增加启动命令配置,例如
command: [ "/bin/bash", "-c", "--" ]
args: [ "while true; do sleep 30; done;" ]
  • 默认后台运行容器改为前台运行,例如
command : [ "nginx", "-g", "daemon off;"]
原文地址:https://www.cnblogs.com/luguojun/p/14294649.html