Dave Sheldon

Dave Sheldon

Tech (and otherwise) Blog

© 2019

Configuring WSL for Docker

Recently, my main workstation died, so I’ve been using an old laptop for my dev work. Even after opening up the case and boosting the RAM from a paltry 16GB to barely-sufficient 24GB, I noticed I was consistently over 90% utilization with Docker and basically anything else (Chrome, Visual Studio, Postman) running. This was immediately visible in the Windows Task Manager. WSL runs under “vmmem.exe” or “VmmemWSL”. If you run a “stock” WSL install and have Docker running, you can probably just sort by “Memory” descending and see it pegged to the top :)

WSL Configuration Options

A couple options exist for configuring WSL. One is to add a wsl.conf to each installed distribution’s /etc directory. The other is to add a ~/.wslconfig to the host. Since I only use WSL for Docker, I went with the latter.

.wslconfig

The Microsoft WSL Config page has a lot of configuration information in it, but if all you’re trying to do is limit RAM (and perhaps also CPU) usage, the provided example is the best place to start. Here’s my own, very simple .wslconfig:

# Settings apply across all Linux distros running on WSL 2
[wsl2]

# Limits VM memory to use no more than 2 GB, this can be set as whole numbers using GB or MB
memory=2GB

# Sets the VM to use one virtual processor
processors=1

Thanks for reading! And as always, if you'd like to leave a comment, go @ me on Twitter.