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)
- Windows starts a lightweight virtual machine.
-
Inside it runs:
- A real Linux kernel (maintained by Microsoft)
- A Linux distribution (e.g., Ubuntu)
-
File systems are mounted:
-
Windows drives →
/mnt/c - Linux root → separate ext4 virtual disk
-
Windows drives →
- Networking is virtualized.
- Processes are isolated but integrated with Windows.
Key Components
| Component | Role |
|---|---|
| Hyper-V technology | Provides virtualization layer |
| Linux kernel | Executes Linux system calls |
| VHDX disk | Stores Linux filesystem |
| WSL service | Manages 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
| Feature | Traditional VM | WSL2 |
|---|---|---|
| Full OS | Yes | Minimal |
| Boot time | Slow | Very fast |
| Memory usage | High | Dynamic |
| Integration | Limited | Deep 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