How to fix CreateContainerConfigError in Kubernetes
CreateContainerConfigError means Kubernetes cannot generate container configuration, usually due to missing ConfigMaps, Secrets, or invalid references. Verify all referenced resources exist.
Quick fix
Fixes CreateContainerConfigError
kubectl describe pod <pod-name>- Identify the missing resource
- Verify ConfigMaps exist
- Verify Secrets exist
- Check the pod specification
kubectl describe pod <pod-name>CreateContainerConfigError
What this error means
CreateContainerConfigError occurs when Kubernetes fails to generate or validate the configuration for a container before creation. Unlike CreateContainerError (failure during creation), this error indicates the configuration itself is invalid or incomplete. The most common cause is referencing a ConfigMap or Secret that doesn't exist in the namespace. Kubernetes cannot build the container's environment variables or volume mounts without these resources, so container creation fails before it begins.
Typical symptoms
- Pod status shows CreateContainerConfigError
- Container never starts - no application logs available
- Events show configmap or secret not found errors
- Pod remains stuck without progressing to ContainerCreating
- Deployment shows pods not ready with config error
- kubectl describe pod shows specific missing resource
Common causes
- ConfigMap referenced by pod does not exist in namespace
- Secret referenced by pod does not exist in namespace
- Specific key referenced does not exist in ConfigMap or Secret
- ConfigMap or Secret exists but has empty data
- Environment variable references non-existent key
- Volume mount references missing ConfigMap or Secret
- Typo in ConfigMap or Secret name
How to fix "CreateContainerConfigError"
Check pod events for the specific error:
kubectl describe pod <pod-name>Look for messages like:
- "Error: configmap \"my-config\" not found"
- "Error: secret \"my-secret\" not found"
- "Error: couldn't find key my-key in ConfigMap"
The message tells you exactly what's missing.
Check if the ConfigMap exists in the correct namespace:
# List ConfigMaps
kubectl get configmaps
# Check specific ConfigMap
kubectl get configmap <name> -o yaml
# Verify the data keys
kubectl get configmap <name> -o jsonpath='{.data}'If missing, create it:
kubectl create configmap my-config --from-literal=key1=value1
# or from file
kubectl create configmap my-config --from-file=config.propertiesCheck if the Secret exists:
# List Secrets
kubectl get secrets
# Check specific Secret (data is base64 encoded)
kubectl get secret <name> -o yaml
# Decode a value
kubectl get secret <name> -o jsonpath='{.data.password}' | base64 -dIf missing, create it:
kubectl create secret generic my-secret --from-literal=password=secret123Review what resources the pod expects:
kubectl get pod <pod-name> -o yaml | grep -A 10 envFrom
kubectl get pod <pod-name> -o yaml | grep -A 10 configMapRef
kubectl get pod <pod-name> -o yaml | grep -A 10 secretRef
kubectl get pod <pod-name> -o yaml | grep -A 10 configMapKeyRefEnsure names match exactly (case-sensitive) and keys exist within the referenced resources.
ConfigMaps and Secrets are namespace-scoped:
# Check pod's namespace
kubectl get pod <pod-name> -o jsonpath='{.metadata.namespace}'
# Ensure ConfigMap is in same namespace
kubectl get configmap <name> -n <namespace>If deploying to different namespaces, create the ConfigMap/Secret in each namespace or use a tool like Sealed Secrets to sync them.
Prevent this error with validation:
# Dry run to catch errors
kubectl apply --dry-run=client -f pod.yaml
# Check if resources exist before deploying
kubectl get configmap my-config || echo "ConfigMap missing!"
kubectl get secret my-secret || echo "Secret missing!"In CI/CD, deploy ConfigMaps and Secrets before Deployments, or use Helm/Kustomize to manage dependencies.
Advanced notes
Optional vs Required references:
# Required - pod fails if missing
envFrom:
- configMapRef:
name: my-config
# Optional - pod starts without it
envFrom:
- configMapRef:
name: my-config
optional: trueUse optional: true for non-critical configuration to prevent startup failures.
For GitOps workflows, ensure ConfigMaps/Secrets are synced before Deployments by using sync waves (ArgoCD) or dependencies (Flux).
When using external secret managers (HashiCorp Vault, AWS Secrets Manager), ensure the External Secrets Operator has synced secrets before pods deploy. Add proper health checks or init containers to wait for secrets.
Frequently asked questions
- What does "CreateContainerConfigError" mean?
- CreateContainerConfigError occurs when Kubernetes fails to generate or validate the configuration for a container before creation. Unlike CreateContainerError (failure during creation), this error indicates the configuration itself is invalid or incomplete. The most common cause is referencing a ConfigMap or Secret that doesn't exist in the namespace.
- How do I fix "CreateContainerConfigError"?
- CreateContainerConfigError means Kubernetes cannot generate container configuration, usually due to missing ConfigMaps, Secrets, or invalid references. Verify all referenced resources exist.
- What causes "CreateContainerConfigError"?
- ConfigMap referenced by pod does not exist in namespace Secret referenced by pod does not exist in namespace Specific key referenced does not exist in ConfigMap or Secret
- Is the "CreateContainerConfigError" error serious?
- It is a medium-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Kubernetes Official Documentation
- ๐
- ๐
- ๐