'Why doesn't htop show my docker-processes using wsl2

Building my container using docker and wsl2 I wanted to see what happens. Running htop in wsl only shows the CPU usage, but none processes running in my containers.

The only information searching for htop, docker and wsl2, the only thing I could find was this archived and unrelated reddit-thread: https://www.reddit.com/r/bashonubuntuonwindows/comments/dia2bw/htop_on_wsl2_doesnt_show_any_processes_while_ps/



Solution 1:[1]

Docker does not run in your default WSL-distro, but in a special Docker-Wsl-distro. Running wsl -l shows the installed distros:

Ubuntu (Standard)
docker-desktop
docker-desktop-data

Docker desktop is based on alpine and you can run top right out of the box:

wsl -d docker-desktop top

If you want htop, you need to install it first:

wsl -d docker-desktop apk update 
wsl -d docker-desktop apk add htop

Running

wsl -d docker-desktop htop

will now give you a nice overview of what is happening in your docker-containers:

htop showing docker processes

Solution 2:[2]

I agree with @Morty.

The following commands give you the list for windows

wsl -l

Then you can run either of the following command

wsl -d  docker-desktop ps
wsl -d  docker-desktop top

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Morty
Solution 2 Rishabh Gupta