如何从 docker 容器中获取主机信息(CPU 利用率)?

锦鲤

我在 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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章