10

I tried giving the below command from container and found the below issue, may be because of "-moby" kernel version. Can't we get a docker image without word "-moby" coming in linux kernel version.

I tried installing linux perf tool on VM having ubuntu and it worked.

#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>
osgx
  • 80,853
  • 42
  • 303
  • 470
Rupesh
  • 101
  • 1
  • 4
  • Do you have a version of perf that works on the host? It may be possible to run that on the container. – Mark Plotnick Oct 10 '17 at 20:38
  • You would need to run `perf` on the Docker VM and I don't think [alpine has a package for it](https://pkgs.alpinelinux.org/contents?file=perf&path=&name=&branch=&repo=&arch=) – Matt Oct 10 '17 at 20:53
  • @MarkPlotnick, I have perf working on host but i don't want to copy the perf binary to container and run it. My objective is to have docker image which can build perf working on any machine. – Rupesh Oct 11 '17 at 11:36
  • Rupesh, check for any linux-tools-* package for your linux, install it, get file list of the package and use real perf binary instead of this **incorrect debian wrapper** script /usr/bin/perf searching for `uname -r` perf (and with wrong "May need ..." message generator). Any `perf` binary (`/usr/lib/linux-tools/*/perf`) can be used with any kernel version (perf_events API is compatible both ways, functionality will be limited with older tool). To build perf package you can build Linux kernel or do it in debian way (apt-get source linux-image...., https://wiki.debian.org/BuildingTutorial) – osgx Oct 23 '17 at 05:37

2 Answers2

9

just do

apt-get install linux-tools-generic

and make a symbolic link to /usr/bin/perf. (in my case):

ln -s /usr/lib/linux-tools/3.13.0-141-generic/perf /usr/bin/perf

it worked for me!

Roozbeh G
  • 337
  • 2
  • 14
  • 1
    This doesn't capture the full complexity. Here are some extra things to worry about: https://stackoverflow.com/questions/38927895/how-do-you-get-debugging-symbols-working-in-linux-perf-tool-inside-docker-contai ; https://stackoverflow.com/questions/44745987/use-perf-inside-a-docker-container-without-privileged . Also, you'd need to run in host pid namespace if you want to see process details instead of a big list of `[Unknown]`,etc... – Valer Sep 05 '19 at 13:08
1

In debian buster-slim i used :

apt-get install linux-perf 

see: https://packages.debian.org/buster/linux-perf

Eyal leshem
  • 788
  • 2
  • 8
  • 16