Skip to content

Troubleshooting guide

CreateContainerConfigError in Kubernetes: how to fix it

CreateContainerConfigError means Kubernetes could not assemble the container's configuration. Nearly always, a referenced Secret or ConfigMap, or one of its keys, is missing.

3 min read9 sectionsUpdated

On this page

Key points

  • The event names the missing object or key.
  • Secrets and ConfigMaps are namespaced.
  • A wrong key name causes this as often as a missing object.
  • The container never started, so there are no logs.

What it means

Before starting a container, the kubelet resolves environment variables and volumes from Secrets and ConfigMaps. If a required reference cannot be resolved, it stops and keeps retrying. Once the missing value exists, the pod starts by itself with no need to redeploy.

Common causes

  • A Secret or ConfigMap that does not exist in the pod's namespace.
  • A key that does not exist inside it, often through a typo or differing case.
  • Deployment order. The workload was applied before its secret.
  • An external secrets operator that failed to sync.
  • runAsNonRoot with an image that runs as root, which gives a similar configuration error.

Diagnose it

The event tells you exactly what is absent. Then compare the keys that exist with those requested.

bash
# The reason, in plain words
kubectl describe pod my-pod | grep -A3 CreateContainerConfigError

# What exists in this namespace?
kubectl get secret,configmap -n prod

# Key names (not values) in a secret
kubectl get secret app-secrets -n prod -o json | python3 -c "import sys,json; print(list(json.load(sys.stdin)['data']))"

# What the pod references
kubectl get pod my-pod -n prod -o yaml | grep -A3 -E 'secretKeyRef|configMapKeyRef|secretRef'

Fixes

Create the missing object in the right namespace, or correct the reference, and the kubelet picks it up on its next retry. Deploy configuration before workloads, using Helm hooks or ordering in your tooling. Check the status of ExternalSecret resources if you use an operator. Use optional: true on a reference only when the application truly works without the value, because otherwise you swap a clear error for a confusing runtime failure.

Catch it automatically

Add a validation step to your pipeline that checks every referenced Secret and ConfigMap exists in the target namespace. Alert on pods waiting in this state, as your Kubernetes monitoring can read waiting reasons directly. A blocked rollout otherwise waits silently.

Frequently asked questions

Does the pod retry automatically?

Yes. Once the Secret or ConfigMap exists, the kubelet starts the container on its next attempt.

Why are there no logs?

The container was never created, so use kubectl describe pod and look at the events.

Can a pod use a Secret from another namespace?

No. Copy it, or use a tool that syncs secrets between namespaces.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.