简体   繁体   English

从docker容器实例中的node.js os.cpus()检索的CPU使用率是否指示主机CPU或容器CPU?

[英]Does the CPU usage retrieved from node.js os.cpus() in a docker container instance indicate host CPU or container CPU?

我正在使用os.cpus()来监视容器实例中的node.js应用程序,但是想知道用法是指示实例的CPU还是docker主机?

For docker containers, there isn't a hard distinction between CPU/mem inside or outside the container like there is virtual machines. 对于docker容器,容器内部或外部的CPU / mem与虚拟机之间没有区别。 Basically, all containers share the same kernel and there isn't a namespace for CPUs or Memory that causes the container to see those differently. 基本上,所有容器共享相同的内核,并且没有CPU或内存的命名空间,导致容器以不同方式查看它们。 Thus, os.cpus() shows the usage information of the host system including all workloads. 因此, os.cpus()显示主机系统的使用信息,包括所有工作负载。 To see usage information for your containers you can use the docker stats command on the host system. 要查看容器的使用信息,可以在主机系统上使用docker stats命令。 For Node.js, checkout the systeminformation package which also provides usage information for docker containers. 对于Node.js,请查看systeminformation包,该包还提供docker容器的使用信息。 However, this is only usable if run on the host (not inside a container)! 但是,这仅在主机(不在容器内)上运行时才可用!

See also: https://docs.docker.com/engine/reference/commandline/stats/ 另见: https//docs.docker.com/engine/reference/commandline/stats/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM