Installing xdebug for lsphp81 on ubuntu 22.04

I'm using the litespeedtech/openlitespeed:1.7.16-lsphp81 docker image with ubuntu 22.04 and I'm trying to set up testing for Wordpress.
The tests run, now I need to set up coverage. This needs xdebug, so I need to install it.

The easy method would be to run apt install php-xdebug but this also installs php 8.1.2-1ubuntu2.8 replacing the previously installed php 8.1.9. This then breaks the tests (server cannot connect to the db).

Another option I found was to follow the xdebug installation wizard. This tells me to install apt-get install php-dev which also installs php 8.1.2-1ubuntu2.8 so I end up with the same problem. Then I found I can apt install lsphp81-dev but this also installs the ubuntu php version...

What would be the correct way to install xdebug for lsphp81 ?
I have tried the method from the first link, but compiling it requires php-dev, or lsphp81-dev in this case. But when I install lsphp81-dev from the package manager, it again installs php 8.1.2-1ubuntu2.8. I can't seem to be able to switch back to lsphp81 after that.

Is there another way to install lsphp81-dev on ubuntu so it does not switch to 8.1.2-1ubuntu2.8?

As for the second link, I don't understand what they are doing there :confused: