Command found but not executable
Production Risk
Container cannot start; must rebuild and redeploy the image.
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.
- 1Entrypoint script was copied into the image without execute permissions (chmod +x missing)
- 2File is owned by root but container runs as non-root without execute bits for others
- 3Dockerfile COPY instruction did not preserve execute permissions
Container exits immediately with code 126; logs show "permission denied" for the entrypoint.
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
# 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
# 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.
Kubernetes Documentation
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev