You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacOS下Podman容器文件观察者耗尽,无法修改sysctl值求助

问题

运行MacOS Sonoma系统,安装了全新的Podman v5.2.0。在Debian上部署了标准NodeJS容器(镜像标签node:20-bookworm-slim),部署NodeJS应用后出现问题:应用通过npm run build:css -- --watch命令监听文件系统变更并自动重载,但启动失败,提示错误:
Error: ENOSPC: System limit for number of file watchers reached

已尝试的修复方案

容器内修复尝试

尝试了所有提升fs.inotify.max_user_watches的标准方法,例如:
echo 'fs.inotify.max_user_watches=524288' | tee -a /etc/sysctl.conf && sysctl -p
但出现错误:
sysctl: permission denied on key "fs.inotify.max_user_watches"

还尝试直接编辑该值:
echo 524288 | dd of=/proc/sys/fs/inotify/max_user_watches
同样报错:
dd: failed to open '/proc/sys/fs/inotify/max_user_watches': Read-only file system

无论尝试何种方法,都无法在容器内修改这些inotify值。

主机端修复尝试

了解到Docker和Podman会继承主机的大部分sysctl值后,尝试在本地MacOS上手动设置maxfiles值:
sudo sysctl -w kern.maxfiles=524288
但重启Debian容器后,执行cat /proc/sys/fs/inotify/max_user_watches查看限制,结果仍为8192。修改Mac主机上的该值对容器内的限制没有任何影响。


内容的提问来源于stack exchange,提问作者ok123jump

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 05:26:02