Docker Desktop eats RAM past WSL limit set in .wslconfig file

So I discovered my error. It seems to be working now now that I fixed it.

The .wslconf & wsl.conf files need to have Unix line endings. When I created mine I had actually done that, but I realized I made the mistake of editing it in Notepad which reverts it back to Windows Standard CR-LF instead of the Unix-style LF.
( Anyone unfamiliar with the Line Endings, a brief explanation: Back in the day Basic ended lines (Return) with a Carriage Return character while other systems would use the Line Fault character. This caused problems because if you opened a file in a program that used a different one from the file everything would be on a single line. Windows, for compatibility used both, so they could deal with Basic (What Mac used) files & the other standard without issue. The characters showed up as essentially a space that didn’t take up space so for text it was perfect. Now they still use the system & a lot of linux programs will see

[ws12]
processors=1
memory=1GB
swapFile=F:\\TMP\\docker\\swap\\wsl-swap.vhdx
swap=16GB
pageReporting=true

as

[ws12]␍
processors=1␍
memory=1GB␍
swapFile=F:\\TMP\\docker\\swap\\wsl-swap.vhdx␍
swap=16GB␍
pageReporting=true␍

so for “How Many Processors?” it thinks you put “1␍” processors & it says “I dunno what you mean”
it’s looking for the swap file in “F:\TMP\docker\swap\wsl-swap.vhdx␍” but there’s no file with that name, etc.

So for a solution there are a couple easy ways to make this work. 1st there’s a utility called Dos2Unix that you can use, I never use it so I can’t tell you much about it, but it’s a CLI tool that essentially just removes the from the end of each line. Or you can use an editor like Notepad++ which has a setting under View > Show Symbol > Show End of Line that will let you see what the file is using. There’s also a simple convert under Edit > EOL Conversion > Unix (LF). Then you just have to remember to edit it with Notepad++ not Notepad.

2 Likes