A repository for building WSL2 Linux kernels with Docker compatibility and BBR (Bottleneck Bandwidth and RTT) support. This project provides automated tools and configurations to patch Microsoft's WSL2 kernel source with the necessary kernel options required for running Docker and improving network performance.
- π³ Docker Compatibility: Automatically patches WSL2 kernel config with all required options for Docker Engine
- π BBR Support: Enables BBR congestion control algorithm for improved network performance
- π§ Automated Scripts: Easy-to-use scripts for fetching and patching kernel configurations
- βοΈ CI/CD Ready: GitHub Actions workflow for automated kernel builds
The default WSL2 kernel provided by Microsoft may not include all the kernel options required for Docker to function properly. This project addresses that by:
- Fetching the latest WSL2 kernel configuration from Microsoft's repository
- Applying patches to enable Docker compatibility options
- Adding BBR congestion control for better network performance
- Providing automated build workflows via GitHub Actions
- Linux or macOS system
bashshellcurlorwget(for fetching configs)sed(usually pre-installed)- Git
- Build tools:
build-essential,flex,bison,dwarves - Libraries:
libssl-dev,libelf-dev - Utilities:
cpio,qemu-utils - Access to Microsoft's WSL2-Linux-Kernel repository
Download the latest WSL2 kernel configuration from Microsoft's repository:
./scripts/fetch-wsl2-config.sh [output-filename]Example:
./scripts/fetch-wsl2-config.sh config-wsl2.cfgThis will download the config to config/config-wsl2.cfg (default location).
Apply Docker and BBR compatibility settings to a kernel configuration file:
./scripts/patch-wsl2-kernel-config.sh <config-file-path>Example:
./scripts/patch-wsl2-kernel-config.sh config/config-wsl2.cfgThe script will:
- Create a backup of the original config file
- Remove existing conflicting configuration entries
- Add all required Docker and BBR options
- Go to the Actions tab in your GitHub repository
- Select the Build workflow
- Click Run workflow
- Configure the build parameters:
- kernelBranch: WSL2-Linux-Kernel branch (default:
linux-msft-wsl-6.6.y) - build-modules: Whether to build kernel modules (default:
false) - custom-config: Use custom config from this repository (default:
false)
- kernelBranch: WSL2-Linux-Kernel branch (default:
- Click Run workflow
The workflow will:
- Checkout the specified WSL2 kernel branch
- Optionally apply your custom configuration
- Build the kernel
- Optionally build kernel modules
- Upload the built kernel (
bzImage) and modules (modules.vhdx) as artifacts
After downloading the artifacts from GitHub Actions:
-
Copy
bzImageto your Windows host (e.g.,C:\Users\<YourUsername>\) -
Create or edit
.wslconfigin your Windows user directory:[wsl2] kernel=C:\\Users\\<YourUsername>\\bzImage
-
Restart WSL2:
wsl --shutdown
The following kernel options are enabled for Docker compatibility:
# Bridge networking
CONFIG_BRIDGE=y
CONFIG_BRIDGE_NETFILTER=y
# Netfilter and iptables
CONFIG_NFT_COMPAT=y
CONFIG_NETFILTER_XT_NAT=y
CONFIG_NETFILTER_XT_TARGET_MASQUERADE=y
CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y
CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y
CONFIG_NETFILTER_XT_MARK=y
# IP tables
CONFIG_IP_NF_IPTABLES=y
CONFIG_IP_NF_FILTER=y
CONFIG_IP_NF_NAT=y
CONFIG_IP_NF_TARGET_MASQUERADE=y
CONFIG_IP_NF_MANGLE=y
# IP Virtual Server
CONFIG_IP_VS=y
CONFIG_NETFILTER_XT_MATCH_IPVS=y
CONFIG_IP_VS_RR=y
# IPsec
CONFIG_XFRM_USER=y
CONFIG_XFRM_ALGO=y
CONFIG_INET_ESP=y
# Network classification
CONFIG_NET_CLS_CGROUP=y
CONFIG_IP_NF_TARGET_REDIRECT=y
# Virtual network interfaces
CONFIG_IPVLAN=y
CONFIG_MACVLAN=y
CONFIG_DUMMY=y
# FTP/TFTP NAT helpers
CONFIG_NF_NAT_FTP=y
CONFIG_NF_CONNTRACK_FTP=y
CONFIG_NF_NAT_TFTP=y
CONFIG_NF_CONNTRACK_TFTP=y
# Filesystem support
CONFIG_BTRFS_FS=yBBR is a TCP congestion control algorithm developed by Google that can significantly improve network throughput and latency:
CONFIG_TCP_CONG_BBR=y
CONFIG_NET_SCH_FQ_CODEL=y
CONFIG_NET_SCH_FQ=yTo enable BBR on your WSL2 instance, add the following to /etc/sysctl.conf:
net.core.default_qdisc=fq
net.ipv4.tcp_congestion_control=bbrThen apply the changes:
sudo sysctl -pwsl2-kernel-build/
βββ config/
β βββ config-wsl2.cfg # Base WSL2 kernel config
β βββ config-wsl2-docker.cfg # Pre-patched config with Docker support
βββ scripts/
β βββ fetch-wsl2-config.sh # Script to fetch latest WSL2 config
β βββ patch-wsl2-kernel-config.sh # Script to patch config with Docker/BBR options
βββ .github/
β βββ workflows/
β βββ build.yml # GitHub Actions build workflow
βββ README.md
If Docker still doesn't work after using a patched kernel:
-
Verify the kernel options are present:
zcat /proc/config.gz | grep CONFIG_BRIDGE -
Check Docker's kernel compatibility requirements:
- Ensure all build dependencies are installed
- Check that you have sufficient disk space (kernel builds require several GB)
- Verify the kernel branch exists in Microsoft's repository