主机上的容器进程

Container process on host machine

我正在使用 Docker 并想确定哪些进程正在 运行 容器上。 所以,我 运行 在我的容器上执行此命令,它将使用近 100% CPU。

md5sum /dev/urandom

之后我在主机上使用 htop 检查了进程。

我如何确定此命令是 运行在容器而不是主机中执行的?

您应该能够添加 cgroup 列,该列标识进程 运行 所在的容器。

  • F2
  • 设置
  • 选择CGROUP
  • F10保存

如“Docker Processes Shown on Host Process List”中所述,您还可以运行 top然后按shift+f 和 select nsPIDnsUSER

nsPID 应该匹配 docker inspect --format='{{ .State.Pid }}' <acontainer>
(如in this example, inspired by the pipework script

另一种选择是运行容器上的命令:

docker exec <container> ps ax

这应该列出容器中的进程 运行ning。

Docker Exec Reference