WSL2 Tips: Limit CPU/Memory When using Docker

WSL2 Tips: Limit CPU/Memory When using Docker

The Windows Subsystem for Linux (WSL) is an ultimate feature from Microsoft that enables developers to run a GNU/Linux environment directly on Windows, unmodified, without the overhead of a traditional virtual machine or the dual-boot setup.

The Windows Subsystem for Linux (WSL) is an ultimate feature from Microsoft that enables developers to run a GNU/Linux environment directly on Windows, unmodified, without the overhead of a traditional virtual machine or the dual-boot setup.

In WSL2, they made lots of performance improvement alongside adding new features such as Managed VM, Full Linux Kernel and Full system call compatibility.

If you enable and install WSL-2 on your Windows, in Docker-desktop can use WSL-2 based engine for better performance.

Image for post

Docker Desktop uses the dynamic memory allocation feature in WSL 2 to greatly improve the resource consumption. This means, Docker Desktop only uses the required amount of CPU and memory resources it needs, while enabling CPU and memory-intensive tasks such as building a container to run much faster.

_— [https://docs.docker.com/docker-for-windows/wsl/_](https://docs.docker.com/docker-for-windows/wsl/)

Dynamic memory allocation and more CPU power! Looks great! But take a look at the following image:

Image for post

Insane memory consumption : Docker on WSL2

Docker on WSL-2 might allocate all available memory, and it eventually causes memory starvation for OS and other applications.

windows-10 wsl wsl-2 docker development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Using WSL 2 to develop Java application on Windows

In this article, I am going to introduce a fourth option (using WSL 2 and X Server) and compare its performance with the first option.

A Linux Dev Environment on Windows with WSL 2, Docker Desktop and More

In this video, we'll go over all of the tools I use on Windows and WSL 2 to create a productive development environment.

How long does it take to develop/build an app?

This article covers A-Z about the mobile and web app development process and answers your question on how long does it take to develop/build an app.

Using WSL 2 with X-Server — Linux on Windows

The Windows Subsystem for Linux lets developers run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

Developer Career Path: To Become a Team Lead or Stay a Developer?

For a developer, becoming a team leader can be a trap or open up opportunities for creating software. Two years ago, when I was a developer, ... by Oleg Sklyarov, Fullstack Developer at Skyeng company