ExitCode 126
KubernetesERRORNotableContainer ErrorHIGH confidence

Command found but not executable

Production Risk

Container cannot start; must rebuild and redeploy the image.

What this means

Exit code 126 means the specified command was found on the filesystem but could not be executed, most commonly because the file lacks execute permissions. This occurs in the container entrypoint or command field and indicates a file permission or filesystem issue in the image.

Why it happens
  1. 1Entrypoint script was copied into the image without execute permissions (chmod +x missing)
  2. 2File is owned by root but container runs as non-root without execute bits for others
  3. 3Dockerfile COPY instruction did not preserve execute permissions
How to reproduce

Container exits immediately with code 126; logs show "permission denied" for the entrypoint.

trigger — this will error
trigger — this will error
kubectl logs mypod --previous
# /bin/sh: /app/entrypoint.sh: Permission denied

kubectl describe pod mypod
# Last State: Terminated  Reason: Error  Exit Code: 126

expected output

/bin/sh: /app/entrypoint.sh: Permission denied

Fix 1

Add execute permission in Dockerfile

WHEN The entrypoint script lacks execute permissions

Add execute permission in Dockerfile
# In your Dockerfile
COPY entrypoint.sh /app/entrypoint.sh
RUN chmod +x /app/entrypoint.sh
ENTRYPOINT ["/app/entrypoint.sh"]

Why this works

chmod +x sets the execute bit so the container runtime can exec the script.

Fix 2

Use explicit interpreter in command

WHEN Quick workaround without rebuilding the image

Use explicit interpreter in command
# In pod spec, override command to invoke shell explicitly
command: ["/bin/sh", "/app/entrypoint.sh"]

Why this works

Invoking the interpreter directly bypasses the need for execute permission on the script file.

Sources
Official documentation ↗

Kubernetes Documentation

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All Kubernetes errors