byGink▻ Sun, 25 May 2025
I think Docker Desktop is the most common tool for containers on Windows. But it turns out consumes a lot of memory and CPU on the device. Not to mention about the unstable connection between the host (Windows) and applications running inside WSL2.
Solution: Just get rid of Docker Desktop and install
docker-ce
right in WSL2. It's so smooth and working without any issues.
This is the common problem with WSL2, when we put files in NTFS folders (from Windows) and try to open them inside WSL.
Solution: Bring your codebase into WSL, install VSCode with WSL extension and things will be fine.
If you're using OpenVPN, it seems to be working smoothly. But WireGuard somehow has a problem.
Solution: Open your WireGuard configuration and edit the client configuration
[Peer]
[Peer]
AllowedIPs = ::/128, 0.0.0.0/1, 128.0.0.0/1
Let's check the default network of WSL
ip link show eth0
In case the MTU is higher than 1420. You have to update it to 1420 manually
sudo ip link set eth0 mtu 1420
This is because of default MTU of WireGuard is 1420. And Docker networks always use default MTU 1500.
Solution: Change the default configuration of Docker to set MTU 1420
/etc/docker/daemon.json
(or create a new one if it doesn't exist) and update it with this setting:{
"mtu": 1420
}
services:
demo:
image: alpine:3.20
container_name: demo_alpine
command: sleep infinity
networks:
- "bridge_network"
networks:
bridge_network:
driver: bridge
driver_opts:
com.docker.network.driver.mtu: 1420
The final solution is modifying your WSL configuration and change it to mirrored
.
This is not recommended because it can cause some conflicts with app running in Windows.
But it can always fix your WSL2 network issues.
C:\Users\<User>\.wslconfig
in Windows (or create a new one) and update this setting[experimental]
networkingMode=mirrored
dnsTunneling=true
Notes: You will need to shutdown your WSL and turn on again to make this change take effect.
After upgrading to Windows 11, I encounter a strange problem with Wi-fi network. When the device is waking up from sleep. The wireless network can't connect again. And even the Wi-fi card driver is disabled in Device Manager.
Turns out the driver was also in sleep mode with Windows but could not be woken up. But checking driver configuration in Device Manager, there's no option to prevent it from sleeping anymore. This happens with Windows 11 only.
Solution: modify the registry to turn on this option:
HKLM\System\CurrentControlSet\Control\Power
Add new DWORD PlatformAoAcOverride (0)
Open Device manager -> Wi-fi Device -> Power Management -> Disable Allow to turn off
Restart and then update PlatformAoAcOverride to (1) again
WSL seems to be not very efficient in resource management
.wslconfig
again and update with some limits[wsl2]
memory=12GB
swap=12GB
processors=8
I've allocated 12GB of RAM and 8 CPU on my device to WSL but you can change with any number you want. Based on your device and the needs.
And if it looks not enough for you. Let's try some other options to make Windows revoke allocated memory faster.
[experimental]
autoMemoryReclaim=dropcache
sparseVhd=true
That's it. Quite a trouble to work with WSL, isn't it? But after finishing all these fixes. I got a smooth experience with it. Just like working on a Linux device.
I hope you get a good experience with it as well. Good luck!
© 2016-2025 GinkCode.com