{"record":{"id":"9e83b84189ad464c","repo":"GoogleContainerTools/skaffold","slug":"statuscheck-container-terminated","errorCode":"STATUSCHECK_CONTAINER_TERMINATED","errorMessage":"container %s terminated with exit code %d","messagePattern":"container (.+?) terminated with exit code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/diag/validator/validator.go","lineNumber":222,"sourceCode":"\nfunc isPodStatusUnknown(pod *v1.Pod) (v1.PodCondition, bool) {\n\tfor _, c := range pod.Status.Conditions {\n\t\tif c.Status == v1.ConditionUnknown {\n\t\t\treturn c, true\n\t\t}\n\t}\n\treturn v1.PodCondition{}, false\n}\n\nfunc getContainerStatus(po *v1.Pod, cs []v1.ContainerStatus) (proto.StatusCode, []string, error) {\n\t// See https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#container-states\n\tfor _, c := range cs {\n\t\tswitch {\n\t\tcase c.State.Waiting != nil:\n\t\t\treturn extractErrorMessageFromWaitingContainerStatus(po, c)\n\t\tcase c.State.Terminated != nil && c.State.Terminated.ExitCode != 0:\n\t\t\tsc, l := getPodLogs(po, c.Name, proto.StatusCode_STATUSCHECK_CONTAINER_TERMINATED)\n\t\t\treturn sc, l, fmt.Errorf(\"container %s terminated with exit code %d\", c.Name, c.State.Terminated.ExitCode)\n\t\t}\n\t}\n\t// No waiting or terminated containers, pod should be in good health.\n\treturn proto.StatusCode_STATUSCHECK_SUCCESS, nil, nil\n}\n\nfunc getUntoleratedTaints(reason string, message string) (proto.StatusCode, error) {\n\tmatches := taintsRe.FindAllStringSubmatch(message, -1)\n\terrCode := proto.StatusCode_STATUSCHECK_UNKNOWN_UNSCHEDULABLE\n\tif len(matches) == 0 {\n\t\treturn errCode, fmt.Errorf(\"%s: %s\", reason, message)\n\t}\n\tmessages := make([]string, len(matches))\n\t// TODO: Add actionable item to fix these errors.\n\tfor i, m := range matches {\n\t\tif len(m) < 2 {\n\t\t\tcontinue\n\t\t}","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/diag/validator/validator.go#L204-L240","documentation":"This error (code STATUSCHECK_CONTAINER_TERMINATED) is raised when a container in the pod has terminated with a non-zero exit code. Skaffold also captures the container logs and returns them so the failure reason can be diagnosed.","triggerScenarios":"getContainerStatus iterates pod container statuses and hits a case where c.State.Terminated != nil && c.State.Terminated.ExitCode != 0; it fetches logs via getPodLogs and returns 'container <name> terminated with exit code <N>'.","commonSituations":"Application crash (panic, unhandled exception), bad entrypoint/command arguments, missing config or env vars causing immediate exit, OOM-killed processes (exit 137), failed readiness-relevant startup logic.","solutions":["Read the captured logs (or kubectl logs <pod> -c <container> --previous) to find the crash stack and exit-code cause.","Fix the application bug or misconfiguration the stack trace points to.","Check kubectl describe pod for OOMKilled / reason, and raise memory limits if exit code 137.","Verify the container command/args match the image's expected entrypoint."],"exampleFix":"// before: wrong flag causes immediate exit\n// args: [\"--port\", \"8080x\"]\n// after\n// args: [\"--port\", \"8080\"]","handlingStrategy":"try-catch","validationCode":"for _, cs := range pod.Status.ContainerStatuses { if cs.State.Terminated != nil && cs.State.Terminated.ExitCode != 0 { return fmt.Errorf(\"%s exited %d: %s\", cs.Name, cs.State.Terminated.ExitCode, cs.State.Terminated.Message) } }","typeGuard":"func hasTerminatedContainer(pod *v1.Pod) (*v1.ContainerStatus, bool) { for i, c := range pod.Status.ContainerStatuses { if c.State.Terminated != nil && c.State.Terminated.ExitCode != 0 { return &pod.Status.ContainerStatuses[i], true } } return nil, false }","tryCatchPattern":"sc, logs, err := getContainerStatus(pod, statuses); if sc == proto.StatusCode_STATUSCHECK_CONTAINER_TERMINATED { return fmt.Errorf(\"container failed, logs:\\n%s\", strings.Join(logs, \"\\n\")) }","preventionTips":["Smoke-test the container image locally (same cmd/args/env) before deploying","Validate config/env/secrets exist at startup with fail-fast messages","Set memory requests/limits to avoid OOMKill (exit 137)","Pin image tags and entrypoint versions to avoid drift"],"tags":["kubernetes","pod","container-crash","exit-code"],"backgroundTag":"container-exited-nonzero","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}