Skip to content
Latchkey

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.

kubectl describe pod
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 directory

Diagnose 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.

Terminal
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 restart

Common 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.

Terminal
kubectl describe pod <pod> | sed -n '/Events/,$p'

Fix by the runtime message

  1. "chdir … no such file or directory" → set a workingDir that exists in the image.
  2. hostPath / subPath error → correct the volume path or pre-create it on the node.
  3. "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 workingDir and command that 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.

Frequently asked questions

What causes Kubernetes "CreateContainerError"?
There are 3 common causes: invalid workingdir or command, mount or device that cannot be set up, and leftover container name conflict. A workingDir/command that does not exist in the image makes the OCI runtime fail at create time (e.g.
How do I fix Kubernetes "CreateContainerError"?
There are 2 fixes depending on which cause you have: read the runtime error verbatim and fix by the runtime message. Work through them in order, since the first is the most common.
What does Kubernetes "CreateContainerError" actually mean?
A pod shows STATUS: CreateContainerError.
How do I stop Kubernetes "CreateContainerError" happening again?
Use a workingDir and command that exist in the image. The prevention section lists 3 changes that keep it from recurring.

Related guides

References

Not every red build is your code. Latchkey repairs the ones that are not, on the runner. Start free → 30-day trial · No credit card