Kubernetes
Debugging
CreateContainerConfigError
Troubleshooting
DevOps

How to debug Kubernetes CreateContainerConfigError

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

CreateContainerConfigError means Kubernetes could schedule the Pod, but the kubelet could not assemble a valid container configuration to start it. The image entrypoint has not run yet, so this is different from an application crash.

The fastest way to debug it is to inspect Pod events and then verify every referenced object: Secrets, ConfigMaps, service accounts, volume sources, and image pull credentials. In most cases, the error is a missing or misspelled dependency rather than a runtime bug.

What the Status Actually Means

A Pod reaches CreateContainerConfigError after scheduling but before container startup. Kubernetes already accepted the manifest, assigned the Pod to a node, and started evaluating the container spec. The failure happens when the kubelet cannot build the final configuration it needs to launch the container.

Typical causes include:

  • a Secret or ConfigMap reference that does not exist
  • a typo in envFrom, valueFrom, or volumeMounts
  • a missing PersistentVolumeClaim
  • an invalid imagePullSecrets reference
  • a service account or projected volume that cannot be resolved

This matters because logs are often empty. Since the container never started, kubectl logs may tell you nothing useful.

A Reliable Debugging Workflow

Start with the Pod description. The Events section usually names the missing object directly.

bash
kubectl get pods -n demo
kubectl describe pod api-7d8d9f6b7c-abcde -n demo
kubectl get events -n demo --sort-by=.lastTimestamp

If the event mentions a missing Secret, ConfigMap, or claim, verify that object exists in the same namespace:

bash
kubectl get secret app-secrets -n demo
kubectl get configmap app-config -n demo
kubectl get pvc app-data -n demo

Then compare the running Pod spec with the manifest you expected to deploy:

bash
kubectl get pod api-7d8d9f6b7c-abcde -n demo -o yaml
kubectl get deploy api -n demo -o yaml

When the problem is not obvious, inspect references section by section.

Common Configuration Mistakes

A very common failure is a missing ConfigMap key. This Pod will fail if LOG_LEVEL is absent from app-config:

yaml
1apiVersion: v1
2kind: Pod
3metadata:
4  name: api
5spec:
6  containers:
7    - name: api
8      image: nginx:1.27
9      env:
10        - name: LOG_LEVEL
11          valueFrom:
12            configMapKeyRef:
13              name: app-config
14              key: LOG_LEVEL

You can confirm the key exists with:

bash
kubectl get configmap app-config -n demo -o yaml

Secret and volume references fail the same way. For example, a Pod that mounts a non-existent Secret will stay in CreateContainerConfigError until you create the Secret or fix the name.

Image authentication is another source of confusion. If the kubelet cannot find the referenced pull secret, you may see a config error first and an image pull error later. Check both the Pod events and the secret type:

bash
kubectl get secret regcred -n demo -o yaml

For private images, the secret should usually be of type kubernetes.io/dockerconfigjson.

How This Differs From Similar Pod States

Do not debug every pending Pod the same way.

  • 'CreateContainerConfigError means the container definition cannot be prepared.'
  • 'ImagePullBackOff means the container definition is fine, but the image cannot be downloaded.'
  • 'CrashLoopBackOff means the container started and then exited repeatedly.'

That distinction tells you where to look. For CreateContainerConfigError, read events and validate references. For CrashLoopBackOff, read application logs. For ImagePullBackOff, check registry access and image names.

A Practical Triage Checklist

Use a short checklist instead of guessing:

bash
1kubectl describe pod POD_NAME -n NAMESPACE
2kubectl get pod POD_NAME -n NAMESPACE -o yaml
3kubectl get secret,configmap,pvc,serviceaccount -n NAMESPACE
4kubectl auth can-i get secrets --as=system:serviceaccount:NAMESPACE:default -n NAMESPACE

That last command is useful when projected credentials or service-account-driven configuration is involved. It does not solve every startup failure, but it quickly rules out an access problem.

Common Pitfalls

The biggest mistake is going straight to kubectl logs. When a container never starts, there may be no logs to inspect. Start with kubectl describe pod instead.

Another common mistake is checking the dependency in the wrong namespace. A Secret named app-secrets in default does not satisfy a Pod running in demo.

Teams also lose time by assuming the Deployment YAML on disk matches the live Pod. Controllers, Helm values, or manual patches can drift. Always inspect the actual Pod manifest with kubectl get pod -o yaml.

Finally, do not lump CreateContainerConfigError together with image pull or runtime failures. The fix is usually in the manifest, not in the application binary.

Summary

  • 'CreateContainerConfigError happens before the container process starts.'
  • 'kubectl describe pod is the most useful first command because events usually reveal the missing reference.'
  • Check Secrets, ConfigMaps, PVCs, service accounts, and image pull secrets in the correct namespace.
  • Use kubectl get pod -o yaml to verify the live configuration, not just the file you intended to deploy.
  • Distinguish this state from ImagePullBackOff and CrashLoopBackOff so you debug the right layer.

Course illustration
Course illustration

All Rights Reserved.