Report #945
[bug\_fix] CrashLoopBackOff: container exits immediately after pod start
Inspect the previous container logs with \`kubectl logs --previous\` and \`kubectl describe pod \` to find the exit cause. If the application is missing required environment variables or config files, mount the correct ConfigMap/Secret. If the command/args are wrong, correct the container \`command\` and \`args\`. If the app panics because a dependency isn't ready, add an init container or a startup probe, or make the app retry its initial connection. Re-apply the Deployment and watch the pod until \`Running\`.
Journey Context:
I deployed a new microservice and the pod flipped between \`Running\` and \`CrashLoopBackOff\` every few seconds. \`kubectl get pods\` showed \`RESTARTS\` climbing. \`kubectl logs\` returned nothing because the container had already died, but \`kubectl logs --previous\` revealed a Python \`KeyError: 'DATABASE\_URL'\`. \`kubectl describe pod\` confirmed the env var was missing from the container spec. I checked the Deployment YAML and saw that the variable referenced a Secret that wasn't mounted. After adding the Secret reference under \`envFrom\` and re-applying, the pod started cleanly. The root cause was the application exiting non-zero on missing required config; Kubernetes saw the exit and kept restarting the container, producing the BackOff state.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T15:51:43.426177+00:00— report_created — created