Kubernetes "CreateContainerError" - Fix Container Create Failures
CreateContainerError means the container runtime accepted the config but failed when it tried to create the container - a missing executable working directory, an invalid mount, or a leftover container with the same name.
What this error means
A pod shows STATUS: CreateContainerError. kubectl describe pod reports a runtime error from containerd/CRI-O - failed to create containerd task, no such file or directory, or container name already in use.
Warning Failed 8s kubelet Error: failed to create containerd task:
failed to create shim task: OCI runtime create failed: ... chdir to cwd
("/app") set in config.json failed: no such file or directoryDiagnose it: read events, not just status
A deployment that never becomes ready has the reason in its events and in the pod state, not in the deployment status. Read both before changing the manifest.
kubectl rollout status deploy/<name> --timeout=120s
kubectl describe deploy/<name> | sed -n "/Events/,$p"
kubectl get pods -l app=<name> -o wide
kubectl describe pod <pod> | sed -n "/Events/,$p"
kubectl logs <pod> --previous --tail=50 # the crash before the restartCommon causes
Invalid workingDir or command
A workingDir/command that does not exist in the image makes the OCI runtime fail at create time (e.g. chdir to cwd "/app" when /app is absent).
Mount or device that cannot be set up
A hostPath that does not exist, a subPath into a missing file, or a device mount the runtime cannot create aborts container creation.
Leftover container name conflict
A stale container from a previous run on the node holds the same name, so the runtime refuses to create a new one until it is cleaned up.
How to fix it
Read the runtime error verbatim
The OCI runtime message names the exact failure - a missing path, a bad mount, or a name clash.
kubectl describe pod <pod> | sed -n '/Events/,$p'Fix by the runtime message
- "chdir … no such file or directory" → set a
workingDirthat exists in the image. - hostPath / subPath error → correct the volume path or pre-create it on the node.
- "name already in use" → the node has a stale container; it usually clears on reschedule, or drain/clean the node.
How to prevent it
- Use a
workingDirandcommandthat exist in the image. - Avoid hostPath mounts in CI deploys; prefer ephemeral or PVC volumes.
- Pin image digests so the entrypoint/layout does not drift unexpectedly.