{
  "id": "docker/exec-format-error-amd64-arm64",
  "signature": "exec /usr/bin/node: exec format error",
  "signature_zh": "执行 /usr/bin/node：执行格式错误",
  "regex": "exec format error",
  "domain": "docker",
  "category": "type_error",
  "subcategory": null,
  "root_cause": "Pulling an AMD64 image on an ARM64 host (or vice versa) without using multi-arch support results in a binary that the host CPU cannot execute.",
  "root_cause_type": "generic",
  "root_cause_zh": "在 ARM64 主机上拉取 AMD64 镜像（反之亦然）且未使用多架构支持时，生成的二进制文件无法在主机 CPU 上执行。",
  "versions": [
    {
      "version": "Docker 24.0.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Docker Desktop 4.22.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Node.js 16.20.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "ARM64 Ubuntu 22.04",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "AMD64 Debian 11",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Reinstalling Node.js in the Dockerfile using apt-get install nodejs",
      "why_fails": "The error is not about missing Node.js but about architecture mismatch; reinstalling the same architecture package yields the same issue.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "Adding 'RUN chmod +x /usr/bin/node' to the Dockerfile",
      "why_fails": "The file already has execute permissions; the error is due to the ELF binary being compiled for a different CPU architecture, not permission issues.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "Setting 'FROM node:16' instead of 'FROM node:16-alpine'",
      "why_fails": "Both variants may default to the same architecture unless explicitly tagged; the tag change does not fix the architecture mismatch.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Specify the platform explicitly in docker run: 'docker run --platform linux/arm64 node:16' on an ARM64 host, or '--platform linux/amd64' on AMD64.",
      "success_rate": 0.95,
      "how": "Specify the platform explicitly in docker run: 'docker run --platform linux/arm64 node:16' on an ARM64 host, or '--platform linux/amd64' on AMD64.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use Docker Buildx to build for multiple architectures: 'docker buildx build --platform linux/amd64,linux/arm64 -t myapp:latest .'",
      "success_rate": 0.9,
      "how": "Use Docker Buildx to build for multiple architectures: 'docker buildx build --platform linux/amd64,linux/arm64 -t myapp:latest .'",
      "condition": "",
      "sources": []
    },
    {
      "action": "Pull a multi-arch manifest by using the official image that supports both architectures, e.g., 'FROM --platform=$BUILDPLATFORM node:16' in your Dockerfile.",
      "success_rate": 0.85,
      "how": "Pull a multi-arch manifest by using the official image that supports both architectures, e.g., 'FROM --platform=$BUILDPLATFORM node:16' in your Dockerfile.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在 docker run 中显式指定平台：在 ARM64 主机上使用 'docker run --platform linux/arm64 node:16'，或在 AMD64 上使用 '--platform linux/amd64'。",
    "使用 Docker Buildx 构建多架构镜像：'docker buildx build --platform linux/amd64,linux/arm64 -t myapp:latest .'",
    "拉取支持多架构的官方镜像的 manifest，例如在 Dockerfile 中使用 'FROM --platform=$BUILDPLATFORM node:16'。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.docker.com/build/building/multi-platform/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-03-08",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}