How to fix Init:RunContainerError in Kubernetes
RunInitError (Init:RunContainerError) occurs when an init container fails to start or execute. Fix the init container configuration, image, or command before the main containers can run.
Quick fix
Fixes Init:RunContainerError
kubectl describe pod <pod-name>- Identify which init container failed
- View init container logs
- Verify init container image and command
- Ensure init container exits
kubectl describe pod <pod-name>Init:RunContainerError
What this error means
RunInitError, shown as Init:RunContainerError in pod status, indicates that an init container failed to start or execute properly. Init containers run sequentially before main application containers, and all init containers must complete successfully before the pod can proceed. This error blocks the entire pod from starting. Unlike main container failures that might trigger restarts, init container failures prevent the pod from ever reaching the Running state until the issue is resolved.
Typical symptoms
- Pod status shows Init:RunContainerError or Init:CrashLoopBackOff
- Pod stuck in PodInitializing state indefinitely
- Status shows Init:1/2 indicating init container progress stalled
- Main application containers never start
- Pod enters restart loop at init container phase
- kubectl logs shows init container errors
Common causes
- Init container image does not exist or cannot be pulled
- Command specified in init container is invalid or missing
- Init container script has errors or missing dependencies
- Init container runs indefinitely instead of completing
- Resource limits too low causing OOMKilled (exit code 137)
- Required ConfigMaps, Secrets, or volumes missing
- Network issues preventing init container from reaching dependencies
How to fix "Init:RunContainerError"
Check init container status:
kubectl describe pod <pod-name>Look at the Init Containers section:
- State: Waiting, Running, or Terminated
- Reason: Why it failed
- Exit Code: 0 (success), 1 (error), 137 (OOMKilled)
Also check:
kubectl get pod <pod-name> -o jsonpath='{.status.initContainerStatuses}'Get logs from the failed init container:
kubectl logs <pod-name> -c <init-container-name>
# If it crashed, get previous logs
kubectl logs <pod-name> -c <init-container-name> --previousThe init container name is defined in your pod spec under initContainers:. Logs reveal the actual error from the container.
Ensure the image exists and command is valid:
# Test the image locally
docker run --rm <init-image> <command>
# Check what command is configured
kubectl get pod <pod-name> -o yaml | grep -A 20 initContainersCommon issues:
- Image tag doesn't exist
- Command path is wrong
- Shell not available in image (use /bin/sh not /bin/bash for alpine)
Init containers MUST complete and exit. They cannot run indefinitely:
# Wrong - runs forever
initContainers:
- name: init
image: busybox
command: ["tail", "-f", "/dev/null"]
# Correct - exits after task
initContainers:
- name: init
image: busybox
command: ["sh", "-c", "until nslookup myservice; do sleep 2; done"]If your init container is meant to wait for something, ensure it has an exit condition.
Exit code 137 means OOMKilled - increase memory:
initContainers:
- name: init-db
image: postgres
resources:
limits:
memory: "256Mi"
requests:
memory: "128Mi"Note: Kubernetes reserves the highest resource request among all init containers (not sum), since they run sequentially.
Init containers often wait for services:
initContainers:
- name: wait-for-db
image: busybox
command: ['sh', '-c', 'until nc -z postgres-service 5432; do echo waiting; sleep 2; done']Check:
- Service exists: kubectl get svc
- DNS resolves: kubectl run test --rm -it --image=busybox -- nslookup <service>
- Port is open: kubectl run test --rm -it --image=busybox -- nc -zv <service> <port>
Advanced notes
Init container restart behavior depends on the pod's restartPolicy:
- Always: Kubelet retries using OnFailure behavior
- OnFailure: Kubelet retries the failed init container
- Never: Entire pod marked as failed
For debugging, you can temporarily remove or comment out the init container to see if the main containers work:
# initContainers:
# - name: problematic-init
# ...Common patterns for init containers:
- Wait for a service to be ready
- Clone git repos or download config
- Run database migrations
- Generate configuration files
Each should be idempotent (safe to retry) and have a clear exit condition.
Frequently asked questions
- What does "Init:RunContainerError" mean?
- RunInitError, shown as Init:RunContainerError in pod status, indicates that an init container failed to start or execute properly. Init containers run sequentially before main application containers, and all init containers must complete successfully before the pod can proceed. This error blocks the entire pod from starting.
- How do I fix "Init:RunContainerError"?
- RunInitError (Init:RunContainerError) occurs when an init container fails to start or execute. Fix the init container configuration, image, or command before the main containers can run.
- What causes "Init:RunContainerError"?
- Init container image does not exist or cannot be pulled Command specified in init container is invalid or missing Init container script has errors or missing dependencies
- Is the "Init:RunContainerError" error serious?
- Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.
Official resources & further reading
- ๐Kubernetes Official Documentation
- ๐Kubernetes Docs: init containers(Official Docs)
- ๐Kubernetes Docs: debug init containers(Official Docs)
- ๐