Fixing CreateContainerConfigError in Kubernetes
A pod stuck in CreateContainerConfigError means kubelet can't build the container config, almost always a ConfigMap or Secret reference that doesn't line up.
Key takeaways
- CreateContainerConfigError means the kubelet could not assemble a container's configuration, usually because a referenced ConfigMap, Secret, or key does not exist in the pod's namespace.
- Run kubectl describe pod and read the Events, which name the missing object and key.
- Create it or fix the reference, and use optional true only for config that is genuinely optional.
On this page
CreateContainerConfigError means the kubelet could not build the container's config, almost always because a ConfigMap, Secret, or key your pod references does not exist in its namespace. Run kubectl describe pod <name> -n <ns>, read the Events, and create the missing object or fix the name, key, or namespace. The image is fine; nothing has started yet.
Verified against
Kubernetes 1.37 (1.37.1), kubectl 1.37, against the kubernetes.io ConfigMap task, Secrets concept and pod debugging pages. Checked October 2026.
The classic wrong turn is staring at the image, convinced the registry is flaky. The image has already pulled. The kubelet has the layers on disk and is ready to start the process. It just can't assemble the configuration the container needs, so it refuses to hand anything to the runtime.
That distinction is the whole game here. This error happens before the container starts, while the kubelet is stitching together environment variables, mounted files, and command arguments from the objects your pod spec points at. If one of those pointers is wrong, the kubelet stops and parks the pod in CreateContainerConfigError. Nothing runs. There's no crash loop to read, because there was never a running process to crash.
What the status actually means
Kubelet builds a container config object for every container in a pod: env vars, volume mounts, the command and args, security context. A lot of that config gets pulled from other Kubernetes objects at start time. An envFrom pulls a whole ConfigMap. A valueFrom.secretKeyRef pulls one key out of a Secret. A volume mounts a ConfigMap as files.
When kubelet resolves those references and one comes back missing, the config build fails and you get this status. The Kubernetes docs put it plainly: if you reference a ConfigMap that doesn't exist and don't mark the reference optional, "the Pod won't start", and the same goes for missing keys. In practice it is nearly always a ConfigMap or Secret that doesn't exist in the namespace, or a key that isn't in the object you named.
Diagnosis: describe names the culprit
Skip the guessing. kubectl describe tells you exactly what's missing, in plain English, in the events at the bottom.
$ kubectl describe pod payments-api-7d9f-abcde -n payments
Scroll to Events. You'll see something like:
Warning Failed kubelet Error: configmap "payments-config" not found
or, when the object exists but the key doesn't:
Warning Failed kubelet Error: couldn't find key DB_HOST in ConfigMap payments/payments-config
That second message is gold. It hands you the namespace, the object name, and the exact key. No log spelunking required.
Confirm what's actually there:
$ kubectl get configmap -n payments
$ kubectl get configmap payments-config -n payments -o jsonpath='{.data}' | jq
$ kubectl get secret payments-secrets -n payments -o jsonpath='{.data}' | jq 'keys'
The common causes, and how to fix each
The ConfigMap or Secret doesn't exist
Usually a namespace mismatch or a typo. ConfigMaps and Secrets are namespaced, and a pod can only reference objects in its own namespace. You applied the ConfigMap to default and the deployment lives in payments. Fix it by creating the object in the right place:
$ kubectl create configmap payments-config \
--from-literal=DB_HOST=pg.payments.svc \
-n payments
If the Secret is supposed to come from an external store, check the sync first: an External Secrets Operator setup that failed to reconcile produces exactly this error, because the Kubernetes Secret never got written.
The referenced key is missing
The object exists, the key doesn't. Here's a broken valueFrom:
# deployment.yaml (container spec)
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: payments-secrets
key: DB_URL # secret actually stores "database-url"
The Secret has database-url, the spec asks for DB_URL, kubelet can't find it, config build fails. Match the key exactly. Casing and hyphens count:
# deployment.yaml (container spec)
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: payments-secrets
key: database-url
Same trap with envFrom, which pulls every key at once:
# deployment.yaml (container spec)
envFrom:
- configMapRef:
name: payments-cfg # object is named "payments-config"
One wrong character and the entire pod won't start. Fix the name to match kubectl get configmap output.
A volume mounts a source that isn't there
The env path gets all the attention, but volumes fail the same way. This mounts a ConfigMap that was never created:
# deployment.yaml (pod spec)
volumes:
- name: app-config
configMap:
name: app-settings # doesn't exist in this namespace
Kubelet can't build the mount, config fails. Create app-settings, or point at the ConfigMap that does exist.
Optional versus required references
This is the escape hatch nobody reads about. Both configMapKeyRef and secretKeyRef accept optional: true. When it's set, a missing object or key leaves that variable or volume empty instead of blocking startup. Useful for config you genuinely might not have in every environment:
# deployment.yaml (container spec)
env:
- name: FEATURE_FLAG_ENDPOINT
valueFrom:
configMapKeyRef:
name: feature-flags
key: endpoint
optional: true
We're cautious with this one. Marking a reference optional to make an error go away is how you ship a pod that runs with a blank DATABASE_URL and fails weirdly at runtime instead of loudly at startup. Use optional only when the config is truly optional, not to silence a real misconfiguration.
Security context the kubelet can't satisfy
Less common, but if your describe output has no ConfigMap or Secret complaint, look at the security context. A pod with runAsNonRoot: true whose image runs as root (and no runAsUser set) fails here with container has runAsNonRoot and image will run as root. Set a numeric non-root runAsUser, or fix the image's USER.
How this differs from CreateContainerError
These two look alike and get conflated constantly. They are not the same failure.
CreateContainerConfigError is a configuration problem. Kubelet couldn't build the config from your references. It never reached the runtime. Fix the ConfigMap, Secret, volume source, or security context.
CreateContainerError is a runtime problem. Config built fine, kubelet handed it to containerd, and the runtime refused to create the container: a bad command path, a missing entrypoint, a name collision, a mount that failed at the OCI layer. The config was valid; the container creation itself broke.
The tell is in the event message. "couldn't find key" or "not found" for a ConfigMap or Secret means Config error, look at your references. Anything about the container runtime, exec paths, or OCI means the plain CreateContainerError, look at the image and command. If the container does start and then dies, you are in different territory, and Kubernetes exit codes is the place to start. For the wider map of pod states and where each one bites, our Kubernetes troubleshooting guide lays them out side by side.
Questions people ask
How do I find which ConfigMap or Secret is missing?
Run kubectl describe pod <pod> -n <namespace> and read the Events section at the bottom. The kubelet's Failed event names the problem directly, for example configmap "payments-config" not found or couldn't find key DB_HOST in ConfigMap payments/payments-config. Then run kubectl get configmap,secret -n <namespace> to compare what exists against what the pod spec references.
Does the pod recover on its own once I create the ConfigMap?
Yes. The kubelet keeps retrying container creation, so once the missing ConfigMap, Secret, or key exists in the pod's namespace, the next attempt succeeds and the pod moves to Running without a redeploy. If you fixed a typo in the pod template instead, the Deployment rolls out new pods. Watch progress with kubectl get pod -w to confirm.
Should I set optional: true to get rid of CreateContainerConfigError?
Only when the value really is optional in some environments. With optional: true, a missing ConfigMap or key leaves the variable or volume empty and the pod starts anyway. That turns a loud startup failure into a quiet runtime bug if the config was actually required, such as a database URL. Fix the reference instead.
The call we'd make
Run kubectl describe pod first, every single time, and read the events before you touch anything. This error is one of the most honest ones Kubernetes gives you. It names the object and the key it couldn't resolve. Diff that against kubectl get configmap and kubectl get secret in the pod's namespace, fix the name, the key, or the namespace, and move on. Reach for optional: true only when the config is genuinely optional. If you're using it to make the red go away, you haven't fixed anything, you've just moved the failure somewhere harder to find.
Sources
Cite this article
Kiril Urbonas (2026). Fixing CreateContainerConfigError in Kubernetes. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/fix-createcontainerconfigerror
[Fixing CreateContainerConfigError in Kubernetes](https://www.devopsness.com/blog/fix-createcontainerconfigerror) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from DevOps
Explore more articles in this category
kaniko CVE-2026-105769: Lookalike ACR Hosts Get Your Azure Token. Rebuild on v1.25.20
A FROM line pointing at a host like x.azurecr.io.attacker.com is enough to make kaniko hand the build's Entra ID token to that host. Which kaniko forks and images are affected, how to find Azure identities in your build pods, and what to rotate.
Sign Container Images With Cosign: Keyless GitHub Actions Workflow, SBOM and In-Cluster Checks
One workflow that builds, signs keylessly with GitHub OIDC, attaches an SBOM and SLSA provenance, plus the Kyverno policy that refuses anything unsigned. Copy it, change three names, ship it.
GitLab CVE-2026-110264: A Second CVSS 10 RCE in Nine Days. Patch to 19.5.1
An unauthenticated regex-compiler RCE reaching back to GitLab 7.0, no workaround, and backports on older branches that fix only the critical bug. The exact version per branch and the commands to get there.
You might have missed
Evergreen posts worth revisiting.