{
  "id": "docker/cgroup-memory-limit-exceeded",
  "signature": "failed to write to \"/sys/fs/cgroup/memory/memory.limit_in_bytes\": device or resource busy",
  "signature_zh": "写入 \"/sys/fs/cgroup/memory/memory.limit_in_bytes\" 失败：设备或资源忙",
  "regex": "failed to write to .*memory\\.limit_in_bytes.*: device or resource busy",
  "domain": "docker",
  "category": "resource_error",
  "subcategory": null,
  "root_cause": "Docker daemon runs inside a container or VM with cgroup v1 where the memory limit file is already set by the host cgroup manager, preventing the container from overriding it.",
  "root_cause_type": "generic",
  "root_cause_zh": "Docker 守护进程在容器或虚拟机中运行，使用 cgroup v1，且内存限制文件已被宿主 cgroup 管理器设置，容器无法覆盖。",
  "versions": [
    {
      "version": "Docker 24.0.7",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "containerd 1.7.13",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Linux 5.15.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Restart Docker daemon with --exec-opt native.cgroupdriver=systemd",
      "why_fails": "Cgroup driver mismatch is not the root cause; the error is about cgroup v1 file being busy, not driver incompatibility.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase memory limit in docker-compose.yml to a very high value",
      "why_fails": "High memory limit does not resolve the device busy error; the issue is at the cgroup file level, not the limit value.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "Run container with --privileged flag",
      "why_fails": "Privileged mode does not bypass cgroup write restrictions; it may even exacerbate cgroup conflicts.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Switch to cgroup v2 by adding 'systemd.unified_cgroup_hierarchy=1' to kernel boot parameters and reboot. Alternatively, set '--cgroup-parent' to a custom path in docker run: docker run --cgroup-parent /docker-custom ...",
      "success_rate": 0.85,
      "how": "Switch to cgroup v2 by adding 'systemd.unified_cgroup_hierarchy=1' to kernel boot parameters and reboot. Alternatively, set '--cgroup-parent' to a custom path in docker run: docker run --cgroup-parent /docker-custom ...",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use 'docker run --memory-swap -1' to disable swap limit and avoid writing to memory.limit_in_bytes when memory is already constrained.",
      "success_rate": 0.75,
      "how": "Use 'docker run --memory-swap -1' to disable swap limit and avoid writing to memory.limit_in_bytes when memory is already constrained.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "切换到 cgroup v2，在内核引导参数中添加 'systemd.unified_cgroup_hierarchy=1' 并重启。或者使用 'docker run --cgroup-parent /docker-custom ...' 设置自定义 cgroup 父路径。",
    "使用 'docker run --memory-swap -1' 禁用交换限制，避免在内存已受限时写入 memory.limit_in_bytes。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://docs.docker.com/config/containers/resource_constraints/#memory",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.78,
  "resolvable": "partial",
  "first_seen": "2024-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}