'Docker consuming more resources than specified in .wslconfig

I created a .wslconfig file following the first answer here to limit wsl resource consumption on my Win10 os. It does not work and I have no clue why. I am using Docker Desktop. File:

# Limit the wsl or vmmem consumption of resources

[wsl2]
memory=3GB # Limits VM memory in WSL 2 to 3 GB
processors=3 # Makes the WSL 2 VM use 3 virtual processors
localhostForwarding=true # Boolean specifying if ports bound to wildcard or localhost in the WSL 2 VM should be connectable from the host via localhost:port.
  • I am using windows build 19042.1526, which should be able to handle such file
  • The file itself is actually a .wslconfig and not an accidental .txt
  • I have restarted my PC and used Restart-Service LxssManager in my admin powershell successfully
  • I am actually using WSL 2
  • I saved the file in C:\Users\PC Paul which is the main user

I am at my wits end, do you have any idea where the problem might be?

Thanks, Paul



Solution 1:[1]

Ok it seems like the file has to start with [wsl2]. I deleted the comment at the top and now it seems to work.

Edit: Further help if it doesn't work may be found here: https://superuser.com/questions/1632543/wslconfig-not-applied-for-wsl2

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