0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DockerのCPU使用率がやばい件

Posted at

CPU使用率が200%を超えた。

スクリーンショット 2025-09-01 125920.png
ファンがぶんぶん回って、パソコンが厚くなっていたので緊急処置。

結論

Windows側のフォルダをコンテナにバインドするな。

windows側で作ったプロジェクトのコンテナをそのまま立ち上げていた。これはNTFS⇄Linuxの境界越えI/O、権限エミュレーション、ウイルススキャン、パス変換などが発生してしまう。

解決策

WSL内の(例)~/dev配下にプロジェクトを置いて、Dockerを起動。

WSL内に置けば、inotifyが使えてI/Oも軽いのでCPU使用率が激減。

inotifyとは
Linuxカーネルが提供しているファイルシステム監視の仕組み。これを使うことで、特定のファイルやディレクトで発生したイベントをリアルタイムに検知できる。

WindowsはLinuxのinotifyを直接使えないので、Docker Desktopが「疑似的に」ファイルを変更、監視をしている。

ここでWSL上のファイルシステムはLinuxネイティブなので、inotifyが直接使えて速い。

/mnt/cはwindowsのCドライブにアクセスするためのもの。Windows 側(/mnt/c)は境界越えI/O(変換・同期・AVスキャン)が入って遅い。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?