(20200622已解决)容器docker||Visual Studio Code is unable to watch for file changes in this large workspa

    技术2024-07-24  19

    问题描述

    如题所述,VSCode无法实时显示文件变动,因为workspace空间太大,文件太多,而linux本身对此有限制。

    From vscode offical documents, you can fixed the problem using:

    # 查看file watcher limit cat /proc/sys/fs/inotify/max_user_watches # increase the limit $ vim /etc/sysctl.conf fs.inotify.max_user_watches=524288 # 新增这么一行 $ sudo sysctl -p

    如果是在docker container内部,上述方案最后会出现:

    sysctl: setting key "fs.inotify.max_user_watches": Read-only file system

    From Increase fs.inotify.max_user_watches in docker container #628, Docker mount /proc as read-only since many of its knobs are global. If you run that same command on the host, the container will transparently inherit the new setting.

    解决方案

    直接在容器所在宿主机上运行上述方案,当宿主机更改,容器也会自动更新。

    References

    “Visual Studio Code is unable to watch for file changes in this large workspace” (error ENOSPC)Increase fs.inotify.max_user_watches in docker container #628
    Processed: 0.037, SQL: 9