When Microsoft introduced WSL2 as a separate Hyper-V VM the resource usage model also changed particulary when combined with using Docker Desktop integrated into the your default WSL2 distribution.

You can find more details in particular from this MS Documentation

Default WSL2 Memory and CPU allocation

For processors, the WSL2 VM is allocated the same number of processors as the Windows host. For Memory, it is allocated 80% of your total memory for Windows builds prior to 20175. After build 20175 that was reduced to 50% of total memory.

Limiting WSL2 Memory and CPU Usage

Shut down your WLS2 VM prior to making any changes to configuration by running the following command:

wsl --shutdown

The %USERPROFILE%/.wslconfig file controls global options. To limit the resource consumption add the following with your preferred settings. Be sure to review the documentation to see what other options are available to change.

As these settings are global, it will apply not only to any WSL instances you create, but also to Docker Desktop as well.
[wsl2]
memory=8GB
processors=4

The WSL2 VM can be started manually by running the following command as an Administrator

sc stop lxssmanager
sc start lxssmanager