Tomas-M / iotop

A top utility for IO
Other
376 stars 50 forks source link

`iotop-c` shows empty screen in docker container running on Windows WSL2 #34

Closed jiasli closed 2 years ago

jiasli commented 2 years ago
> docker run -it --rm registry.access.redhat.com/ubi8/ubi:8.4

# This doesn't work
# yum install epel-release -y
Updating Subscription Management repositories.
Unable to read consumer identity

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Red Hat Universal Base Image 8 (RPMs) - BaseOS                                          192 kB/s | 798 kB     00:04
Red Hat Universal Base Image 8 (RPMs) - AppStream                                       2.8 MB/s | 2.6 MB     00:00
Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder                                35 kB/s |  17 kB     00:00
No match for argument: epel-release
Error: Unable to find a match: epel-release

# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# yum install iotop-c -y
# iotop-c

or

> docker run -it --rm fedora

# yum install iotop-c -y
# iotop-c

image

# iotop-c --version
iotop-c 1.20
bbonev commented 2 years ago

iotop uses kernel functionality that is not available in containers, unless the container has the –privileged flag (which is a bad idea on its own).

Can you retest your scenario with the latest git tree of iotop-c? There are changes that address this situation by emitting a proper error message.

jiasli commented 2 years ago

Thanks @bbonev for the quick response. Indeed, the latest version shows a proper error message:

# iotop --version
iotop 1.21
# iotop
nl_init: couldn't get netlink family id

but it still seems not to work with --privileged:

> docker run -it --rm --privileged fedora
# yum install git gcc make ncurses-devel pkgconfig -y
# git clone https://github.com/Tomas-M/iotop
# cd iotop
# make -j
# make install
# iotop
nl_init: couldn't get netlink family id

BTW, fixed a small error in the URL: https://github.com/Tomas-M/iotop/pull/35 😉

bbonev commented 2 years ago

Maybe it is my mistake (--privileged) because I am not too well aware of containers' terminology and options - that should be something like super-privileged or admin-privileged. While it may be a good option for testing, running a container in that mode is a big NO...

iotop uses Linux kernel's netlink interface for fetching the processes' IO counters and this part of the kernel is not (yet) virtualised and hence not accessible in containers. See #28 for more info.