{
  "id": "docker/build-cache-mount-conflict",
  "signature": "failed to solve: failed to compute cache key: mount /cache: already mounted in build stage",
  "signature_zh": "求解失败：计算缓存键失败：挂载/cache：已在构建阶段挂载",
  "regex": "failed to compute cache key.*mount.*already mounted",
  "domain": "docker",
  "category": "build_error",
  "subcategory": null,
  "root_cause": "A RUN --mount=type=cache directive in Dockerfile tries to mount the same cache directory twice in the same build stage, causing a conflict.",
  "root_cause_type": "generic",
  "root_cause_zh": "Dockerfile中的RUN --mount=type=cache指令尝试在同一构建阶段两次挂载相同的缓存目录，导致冲突。",
  "versions": [
    {
      "version": "Docker 25.0.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "BuildKit 0.12.5",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Removing all --mount directives without understanding the conflict loses cache benefits and may break the build.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using different cache IDs for the same mount path still causes conflict because the path is already mounted.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Merge the two RUN commands into one that uses a single --mount=type=cache, or use different mount paths: RUN --mount=type=cache,target=/cache/apt ... && ...",
      "success_rate": 0.85,
      "how": "Merge the two RUN commands into one that uses a single --mount=type=cache, or use different mount paths: RUN --mount=type=cache,target=/cache/apt ... && ...",
      "condition": "",
      "sources": []
    },
    {
      "action": "Restructure Dockerfile to use separate stages for each cache mount: FROM base AS builder1 with /cache/apt, then FROM base AS builder2 with /cache/pip.",
      "success_rate": 0.8,
      "how": "Restructure Dockerfile to use separate stages for each cache mount: FROM base AS builder1 with /cache/apt, then FROM base AS builder2 with /cache/pip.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "将两个RUN命令合并为一个使用单一--mount=type=cache的指令，或使用不同的挂载路径：RUN --mount=type=cache,target=/cache/apt ... && ...",
    "重构Dockerfile，为每个缓存挂载使用单独的构建阶段：FROM base AS builder1使用/cache/apt，然后FROM base AS builder2使用/cache/pip。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.docker.com/build/cache/",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-04-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}