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

  • 問題描述

    如題所述,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

  1. “Visual Studio Code is unable to watch for file changes in this large workspace” (error ENOSPC)
  2. Increase fs.inotify.max_user_watches in docker container #628
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章