INNER CODE UNIT · Python
_diagnose_bwrap_failure
ArcReel/ArcReel · server/app.py:111
def _diagnose_bwrap_failure() -> str:
"""根据 host sysctl 状态给出 bwrap 失败的精确修复路径。
procfs 是宿主机共享的,容器内同样能读到 host sysctl 值,所以这套
诊断在 docker 内外都能跑。优先级:Ubuntu 24.04 AppArmor 限制 >
传统 unprivileged_userns_clone > max_user_namespaces > 兜底容器配置。
"""
parts: list[str] = []
apparmor_userns = _read_sysctl(_APPARMOR_USERNS_SYSCTL)
if apparmor_userns == "1":
parts.append(
"Detected Ubuntu 24.04+ AppArmor restriction (root cause):\n"
" /proc/sys/kernel/apparmor_restrict_unprivileged_userns = 1\n"
" Blocks ALL unprivileged user namespaces. `apparmor:unconfined`\n"
" in docker compose does NOT bypass this — it is a global LSM\n"
" switch, not a per-process profile.\n"
" Fix on HOST (not inside the container):\n"