-
-
Notifications
You must be signed in to change notification settings - Fork 56
Docker on Windows (WSL 2)
This guide provides tips on optimizing Docker's performance on Windows by adjusting WSL 2 settings.
To manage Docker's resource consumption more effectively, you can configure WSL 2 to limit the amount of memory and CPU cores Docker can use.
Here’s how to do it:
-
Create a Configuration File: Navigate to your user directory (
%USERPROFILE%
) and create a new file named.wslconfig
. -
Edit the Configuration: Open the
.wslconfig
file in a text editor and include the following settings:
[wsl2]
memory=2GB # Limits WSL 2 to use up to 2GB of RAM
processors=2 # Limits WSL 2 to use up to 2 CPU cores
swap=2GB # Specifies the swap size
These settings restrict Docker to a maximum of 2GB of RAM and 2 CPU cores, but you can adjust the values based on your system's specifications.
-
Apply the Changes: Save the
.wslconfig
file and restart WSL 2 for the changes to take effect.
You can restart WSL 2 by restarting your computer or by executing the command wsl --shutdown
in the Windows Command Prompt or PowerShell, then reopening your WSL 2 terminal.
For more detailed information on configuring WSL 2, refer to the official Microsoft documentation.