McKube 0 requests sent

Exec Format Error (amd64 vs arm64 Architecture Mismatch)

Fix Exit 255 / 126 'exec format error' when an Apple Silicon arm64 image runs on amd64 Linux nodes or vice versa.

HIGH · Exec Format Error

Root Cause

The container entrypoint binary was compiled for a different CPU instruction set than the worker node kernel (most commonly a local arm64 build pushed to an amd64 EKS/GKE/AKS node pool).

Why It Happens

When the Linux kernel tries to execve() an ELF binary for the wrong architecture, it immediately returns ENOEXEC ('exec format error') and the container crashes on line 0 with Exit 255 or 126. Building multi-architecture OCI manifests via docker buildx avoids the trap across mixed x86 and Graviton/Arm clusters.

What It Looks Like in kubectl describe

Name:         web-1
Namespace:    web
Containers:
  web:
    Last State:     Terminated
      Reason:       Error
      Exit Code:    255
logs: exec /usr/local/bin/web: exec format error

How to Fix

  • Check worker node CPU architectures with kubectl get nodes.
  • Build and push a multi-arch image (`docker buildx build --platform linux/amd64,linux/arm64 --push`).
  • If using mixed arch node pools for single-arch images, add a nodeSelector for `kubernetes.io/arch`.

Diagnostic Commands

kubectl get nodes -o custom-columns=NAME:.metadata.name,ARCH:.status.nodeInfo.architecture
kubectl get pod <pod> -n <ns> -o jsonpath='{.spec.containers[*].image}'