What Is CreateContainerConfigError?
CreateContainerConfigError means Kubernetes accepted your Pod spec but cannot create the container because something in the configuration is invalid or missing. The Pod stays in Pending or shows CreateContainerConfigError in the STATUS column:
kubectl get podsNAME READY STATUS RESTARTS AGE
my-app-7b8f9d4c6-x2k4j 0/1 CreateContainerConfigError 0 2mUnlike CrashLoopBackOff (container starts then dies) or ImagePullBackOff (image not found), CreateContainerConfigError means the container never starts because its configuration references something that does not exist or is malformed.
Step 1: Get the Error Details
kubectl describe pod my-app-7b8f9d4c6-x2k4jScroll to the Events section at the bottom. The error message tells you exactly what is wrong. Here are the most common causes and fixes.
Cause 1: Missing ConfigMap
Error message:
Warning Failed configmap "app-config" not foundThe Pod references a ConfigMap that does not exist in the namespace.
Diagnose:
kubectl get configmap app-config -n <namespace>Fix β Create the missing ConfigMap:
kubectl create configmap app-config \
--from-literal=DATABASE_HOST=postgres \
--from-literal=DATABASE_PORT=5432 \
-n <namespace>Or from a file:
kubectl create configmap app-config \
--from-file=config.yaml=./config.yaml \
-n <namespace>Prevention: Use optional: true in your Pod spec if the ConfigMap is not critical:
envFrom:
- configMapRef:
name: app-config
optional: trueCause 2: Missing Secret
Error message:
Warning Failed secret "db-credentials" not foundDiagnose:
kubectl get secret db-credentials -n <namespace>Fix:
kubectl create secret generic db-credentials \
--from-literal=username=admin \
--from-literal=password=s3cur3p4ss \
-n <namespace>Common gotcha: Secrets are namespace-scoped. If you created the Secret in default but the Pod runs in production, it will not find it.
# Check which namespace the Pod is in
kubectl get pod my-app-7b8f9d4c6-x2k4j -o jsonpath='{.metadata.namespace}'Cause 3: Missing Secret Key
Error message:
Warning Failed couldn't find key "password" in Secret default/db-credentialsThe Secret exists but is missing the specific key your Pod references.
Diagnose:
kubectl get secret db-credentials -o jsonpath='{.data}' | jqFix β Add the missing key:
kubectl patch secret db-credentials -p '{"data":{"password":"czNjdXIzcDRzcw=="}}'Note: Secret values must be base64-encoded:
echo -n "s3cur3p4ss" | base64Cause 4: Volume Mount Referencing Missing ConfigMap or Secret
Error message:
Warning Failed configmap "nginx-config" not foundWhen a volume references a ConfigMap or Secret that does not exist:
volumes:
- name: config-volume
configMap:
name: nginx-config # This ConfigMap must existFix: Create the ConfigMap or mark it optional:
volumes:
- name: config-volume
configMap:
name: nginx-config
optional: trueCause 5: Invalid Security Context
Error message:
Warning Failed Error: container has runAsNonRoot and image will run as rootThe Pod security context requires non-root, but the container image runs as root.
Fix β Option A: Set runAsUser in the Pod spec:
securityContext:
runAsUser: 1000
runAsNonRoot: trueFix β Option B: Use an image that runs as non-root:
FROM nginx:alpine
RUN adduser -D -u 1000 appuser
USER appuserFix β Option C: Remove the restriction (not recommended for production):
securityContext:
runAsNonRoot: falseCause 6: Invalid Resource Requests
Error message:
Warning Failed Error: invalid resource quantityMalformed resource requests or limits:
# WRONG - missing unit
resources:
requests:
memory: 256 # Should be "256Mi"
cpu: 100 # Should be "100m"Fix:
resources:
requests:
memory: "256Mi"
cpu: "100m"
limits:
memory: "512Mi"
cpu: "500m"Cause 7: ServiceAccount Token Mount Failure
Error message:
Warning Failed serviceaccount "my-sa" not foundDiagnose:
kubectl get serviceaccount my-sa -n <namespace>Fix:
kubectl create serviceaccount my-sa -n <namespace>Cause 8: Projected Volume Configuration Error
Error message:
Warning Failed projected volume source is invalidProjected volumes combine multiple sources. Any misconfigured source blocks the container:
volumes:
- name: combined
projected:
sources:
- configMap:
name: app-config # Must exist
- secret:
name: app-secret # Must exist
- serviceAccountToken:
expirationSeconds: 3600Fix: Verify each source exists individually.
Quick Diagnostic Script
Run this to check all common causes at once:
#!/bin/bash
POD=$1
NS=${2:-default}
echo "=== Pod Events ==="
kubectl describe pod $POD -n $NS | grep -A 20 "Events:"
echo -e "\n=== ConfigMap References ==="
kubectl get pod $POD -n $NS -o json | \
jq -r '.. | .configMapRef?.name // .configMap?.name // empty' | \
sort -u | while read cm; do
kubectl get configmap $cm -n $NS &>/dev/null && \
echo " β
$cm exists" || echo " β $cm MISSING"
done
echo -e "\n=== Secret References ==="
kubectl get pod $POD -n $NS -o json | \
jq -r '.. | .secretRef?.name // .secretKeyRef?.secretName // .secret?.secretName // empty' | \
sort -u | while read s; do
kubectl get secret $s -n $NS &>/dev/null && \
echo " β
$s exists" || echo " β $s MISSING"
done
echo -e "\n=== ServiceAccount ==="
SA=$(kubectl get pod $POD -n $NS -o jsonpath='{.spec.serviceAccountName}')
kubectl get serviceaccount $SA -n $NS &>/dev/null && \
echo " β
$SA exists" || echo " β $SA MISSING"Save as debug-createcontainerconfigerror.sh and run:
chmod +x debug-createcontainerconfigerror.sh
./debug-createcontainerconfigerror.sh my-app-7b8f9d4c6-x2k4j defaultPrevention Checklist
| Check | Command |
|---|---|
| ConfigMaps exist | kubectl get cm -n <ns> |
| Secrets exist | kubectl get secret -n <ns> |
| ServiceAccount exists | kubectl get sa -n <ns> |
| Resource format valid | Review YAML for units (Mi, Gi, m) |
| Security context compatible | Check image USER directive |
| Namespace correct | kubectl config current-context |
| Optional flags set | Add optional: true for non-critical configs |
Common Mistakes
- Wrong namespace β most common cause. ConfigMap in
default, Pod inproduction - Typo in ConfigMap/Secret name β Kubernetes is case-sensitive
- Forgot to apply ConfigMap β your Helm chart or Kustomize overlay did not include it
- Secret key mismatch β the key in
secretKeyRef.keymust exactly match a key in the Secret data - Base64 encoding issues β Secrets with newlines or special characters in base64
When It Is Not CreateContainerConfigError
If you see similar symptoms but different status:
ImagePullBackOffβ image does not exist or registry auth is wrong β Fix ImagePullBackOffCrashLoopBackOffβ container starts but exits β Fix CrashLoopBackOffPendingβ no node has enough resources β Fix Pod PendingOOMKilledβ out of memory β Fix OOMKilled
Need help debugging Kubernetes in production? I help teams build reliable platforms with proper ConfigMap management, secret rotation, and deployment guardrails.