Search code examples
docker-for-windowswindows-subsystem-for-linux

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

  • 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