CreateContainerError: the runtime could not create the container

Reproduced on k3s v1.31.5 (k3d) with kubectl v1.36.1.

What you see

# image with no ENTRYPOINT or CMD, and no command in the pod spec
$ kubectl get pod nocmd-demo -n lab
NAME         READY   STATUS                 RESTARTS   AGE
nocmd-demo   0/1     CreateContainerError   0          2m35s

$ kubectl get events -n lab --field-selector involvedObject.name=nocmd-demo --sort-by=.lastTimestamp
63s   Warning   Failed   pod/nocmd-demo   Error: failed to generate container "c503..." spec: failed to generate spec: no command specified

# command points at a binary that is not in the image
$ kubectl get pod badcmd-demo -n lab
NAME          READY   STATUS              RESTARTS      AGE
badcmd-demo   0/1     RunContainerError   4 (12s ago)   104s

$ kubectl describe pod badcmd-demo -n lab
    Last State:     Terminated
      Reason:       StartError
      Message:      failed to create containerd task: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: exec: "/app/server": stat /app/server: no such file or directory: unknown
      Exit Code:    128

What it means

Starting a container has two runtime steps. First the runtime creates it from the image and spec. Then it starts the process. CreateContainerError means the first step failed. RESTARTS stays at 0 because nothing ran.

If the create works but the process cannot start, you get a different status. On containerd with runc, a command pointing to a missing binary failed at start. The pod showed RunContainerError, then CrashLoopBackOff, with Last State reason StartError and exit code 128. Some guides list a bad command under CreateContainerError. Check which status you actually have before you follow one.

CreateContainerConfigError is a third, earlier failure. There the kubelet could not even build the config. See that page for missing ConfigMaps and Secrets.

Common causes

No command to run

The image has no ENTRYPOINT or CMD and the pod spec sets no command. Minimal and distroless base images often ship like this.

How to tell: The message says failed to generate spec: no command specified.

Container name is reserved

The runtime still holds a container with the same name from an earlier attempt, often after a runtime restart or a slow node.

How to tell: The message says the name is reserved for another container ID.

Mount or device setup fails in the runtime

The runtime cannot set up a mount, device or path from the spec. For example the host path type does not match.

How to tell: The message names a mount path or device and an OS error such as not a directory.

Missing binary or wrong path (often a different status)

The command or entrypoint points to a file that is not in the image. With containerd this usually fails at start, not create.

How to tell: RunContainerError or CrashLoopBackOff, Last State reason StartError, exit code 128 and a message with no such file or directory.

How to diagnose it

  1. kubectl get pod <pod> -n <namespace> -o jsonpath='{.status.containerStatuses[*].state.waiting}'

    Shows the reason and the runtime's message. The message is the useful part.

  2. kubectl get pod <pod> -n <namespace> -o jsonpath='{.status.containerStatuses[*].lastState.terminated}'

    If this has reason StartError and exitCode 128, the create worked and the start failed. Treat it as a bad command or entrypoint.

  3. kubectl get events -n <namespace> --field-selector involvedObject.name=<pod> --sort-by=.lastTimestamp

    Failed events repeat the runtime error on each retry. Check it is the same error every time.

  4. kubectl get pod <pod> -n <namespace> -o jsonpath='{.spec.containers[*].command} {.spec.containers[*].args}'

    Compare with the image's ENTRYPOINT and CMD. You can read those with docker image inspect <image> or crane config <image>.

  5. kubectl describe node <node>

    For reserved-name or mount errors, check if the node had a runtime restart or disk issues around the same time.

How to fix it

Set command in the pod spec

Give the container an explicit command that exists in the image.

containers:
- name: app
  image: <image>
  command: ["/app/server"]
  args: ["--port=8080"]

Trade-off: The pod spec now overrides the image. If the image changes its binary path later, the pod breaks again.

Fix the image

Add the right ENTRYPOINT or CMD to the Dockerfile, or copy the binary to the path the spec expects.

Trade-off: Needs a new build and release. Check the image locally before pushing.

Clear the stuck container

For reserved-name errors, delete the pod so its controller makes a new one. If it keeps happening on one node, restart the runtime there.

Trade-off: Restarting the runtime on a node affects every pod on that node. Cordon and drain it first.

How to stop it coming back

  • Run each new image once in CI with the same command and args as the pod spec.
  • When moving to a distroless or minimal base, check that ENTRYPOINT is still set.
  • Alert on CreateContainerError and RunContainerError together. They need the same first step: read the runtime message.

How KubeGraf investigates it

Agents propose competing explanations and cite the evidence behind each one. How KubeGraf handles Kubernetes incidents.

Frequently asked questions

What is the difference between CreateContainerError and RunContainerError?

CreateContainerError happens when the runtime refuses to create the container. A missing binary or a wrong path usually appears as RunContainerError or StartError instead, after creation succeeded.

Why does it say there is no command to run?

The image has no entrypoint and the pod spec sets no command, so the runtime has nothing to start. Set command in the pod spec.

What does a reserved container name mean?

The name the runtime was asked to use is already taken, so creation fails. It usually clears once the old container is gone.

Where do I find the real error?

In the waiting message on the pod status, which carries the runtime's own text. Run kubectl describe pod and read it before changing anything.

Last updated . Try KubeGraf Freemium.

Related

Kubernetes documentation