我在 docker 容器中运行 node.js 应用程序(因为我无法在我们的机器上安装 node)。我的应用程序使用 systeminformation 包来获取 cpu 利用率,但这是 docker 容器的 cpu 利用率。我想要在主机上运行的进程的 CPU 利用率。
这能做到吗?
使用带有--pid=host
选项的主机的 PID 命名空间docker run
。
从联机帮助页:
--pid="" Set the PID mode for the container Default is to create a private PID namespace for the container 'container:<name|id>': join another container's PID namespace 'host': use the host's PID namespace for the container. Note: the host mode gives the container
完全访问本地PID,因此被认为是不安全的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句