Pages

What is Windows Subsystem for Linux version 2(WSL2)?

What is WSL2?

WSL2 (Windows Subsystem for Linux version 2) is a Microsoft virtualization layer that allows you to run a real Linux kernel inside Windows 11.

It enables native Linux binaries to execute directly on Windows without using a traditional virtual machine like VirtualBox or VMware Workstation.


Architecture Overview

WSL1 (Old Model)

  • Translation layer
  • Converted Linux system calls into Windows NT kernel calls
  • No real Linux kernel
  • Limited compatibility

WSL2 (Current Model)

  • Uses a real Linux kernel
  • Runs inside a lightweight utility VM
  • Uses virtualization technology (Hyper-V architecture)
  • Full system call compatibility

How WSL2 Works (Technical Flow)

  1. Windows starts a lightweight virtual machine.
  2. Inside it runs:
    • A real Linux kernel (maintained by Microsoft)
    • A Linux distribution (e.g., Ubuntu)
  3. File systems are mounted:
    • Windows drives → /mnt/c
    • Linux root → separate ext4 virtual disk
  4. Networking is virtualized.
  5. Processes are isolated but integrated with Windows.

Key Components

ComponentRole
Hyper-V technologyProvides virtualization layer
Linux kernelExecutes Linux system calls
VHDX diskStores Linux filesystem
WSL serviceManages lifecycle

Why WSL2 Is Important for Docker

Docker requires:

  • Linux kernel features (namespaces, cgroups)
  • Container isolation primitives

WSL2 provides those natively.

So when Docker runs on Windows 11:

  • Docker engine runs inside WSL2
  • Containers run inside Linux environment
  • Windows interacts through CLI

This avoids the heavy VM approach used before.


Performance Characteristics

CPU

Near-native performance.

File System

  • Fast inside Linux filesystem (/home)
  • Slower when accessing Windows drives (/mnt/c)

Best practice:
Store Docker projects inside WSL filesystem.


Advantages of WSL2

  • Full Linux compatibility
  • Fast boot time
  • Low memory footprint (dynamic allocation)
  • Seamless Windows ↔ Linux integration
  • Required for modern Docker Desktop

Limitations

  • Uses virtualized networking (different IP)
  • Separate Linux filesystem
  • Not a full GUI desktop (unless configured)
  • Requires virtualization enabled

Practical Example

After installing WSL2:

wsl

You are now inside Linux.

Install packages normally:

sudo apt update
sudo apt install nginx

You are running real Linux inside Windows.


Conceptual Comparison

FeatureTraditional VMWSL2
Full OSYesMinimal
Boot timeSlowVery fast
Memory usageHighDynamic
IntegrationLimitedDeep Windows integration

Summary

WSL2 is:

  • A lightweight virtualized Linux environment
  • Powered by a real Linux kernel
  • Deeply integrated into Windows 11
  • Essential for Docker and modern dev workflows