是否可以在docker容器中运行linux perf工具

Rup*_*esh 5 linux containers perf docker moby

我尝试从容器中给出以下命令,发现下面的问题,可能是因为"-moby"内核版本.我们不能在Linux内核版本中没有"-moby"字样的情况下获得docker镜像.

我尝试在拥有ubuntu的VM上安装linux perf工具,但它确实有效.

#docker run -t -i ubuntu:14.04 /bin/bash

root@214daea94f4f:/# perf

WARNING: perf not found for kernel 4.9.41

You may need to install the following packages for this specific kernel:

linux-tools-4.9.41-moby
linux-cloud-tools-4.9.41-moby

You may also want to install one of the following packages to keep up to date:

linux-tools-moby-lts-<series>
linux-cloud-tools-moby-lts-<series>
Run Code Online (Sandbox Code Playgroud)

Roo*_*h G 6

做就是了

apt-get install linux-tools-generic
Run Code Online (Sandbox Code Playgroud)

并创建一个符号链接到/ usr/bin/perf.(在我的情况下):

ln -s /usr/lib/linux-tools/3.13.0-141-generic/perf /usr/bin/perf
Run Code Online (Sandbox Code Playgroud)

它对我有用!

  • 这并没有体现出全部的复杂性。这里有一些额外的事情需要担心:/sf/ask/2724952681/;/sf/ask/3132219121/ 。另外,如果你想查看进程详细信息而不是一大堆“[Unknown]”等,你需要在主机 pid 命名空间中运行。 (2认同)