Run Linux Containers Natively on Windows Without Docker: A Hands‑On Guide to WSL Containers
Microsoft’s WSL Containers, now in public preview, embed a Docker‑compatible container runtime directly into WSL 2, letting Windows developers launch OCI images with familiar commands without installing Docker Desktop, while the article walks through installation, core components, command mapping, performance benchmarks, feature gaps and current limitations.
What is WSL Containers?
WSL Containers is a built‑in Linux container runtime that ships with the latest WSL 2 update. It runs standard OCI images (e.g., ubuntu, nginx, nvidia/cuda) inside a lightweight Hyper‑V VM that shares the same kernel mechanism as WSL 2. It is not a new version of WSL; it is an additional feature layered on top of the existing WSL 2 infrastructure.
Core Components
wslc.exe(also available as container.exe) – a command‑line tool whose syntax mirrors Docker’s (e.g., docker run, docker ps).
WSL Container API – distributed as a NuGet package for C, C++, and C#. It enables native Windows applications to launch and control Linux containers programmatically and can be integrated into MSBuild or CMake pipelines.
Installation (5 steps)
Open Windows Terminal as Administrator (PowerShell).
Enable WSL 2 and the Virtual Machine Platform feature if not already present:
Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux","VirtualMachinePlatform"Upgrade WSL to the pre‑release channel: wsl --update --pre-release Restart WSL to apply the update: wsl --shutdown Verify the installation: wslc version which should display a version such as 2.9.3.0. Then run a test container:
wslc run --rm hello-worldSystem Requirements
Windows 11 (or Windows 10 22H2+), a 64‑bit CPU with SLAT, at least 4 GB RAM (8–16 GB recommended), and virtualization enabled in BIOS/UEFI. No Copilot + PC license is required.
Command reference (Docker ↔ WSL Containers)
Run a container : docker run --rm -it ubuntu bash → wslc run --rm -it ubuntu:latest bash Expose a web service : docker run -d -p 8080:80 nginx → wslc run -it --rm -d -p 8080:80 --name web nginx List containers : docker ps → wslc container ps List images : docker images → wslc image ls Stop a container : docker stop web → wslc container stop web Build an image : docker build -t myapp . → wslc build -t myapp:latest . GPU passthrough : docker run --gpus all ... →
wslc run --gpus all nvidia/cuda:12.2.0-base-ubuntu22.04 nvidia-smiWSL Containers vs. Docker Desktop
Installation : Built‑in with WSL updates vs. separate installer.
Price : Free (included in Windows) vs. commercial license (≈ $24/user, enterprise tier required for >250 users).
Enterprise management : GPO/ADMX templates, image allow‑list, Intune (coming), Defender integration vs. Docker Business needed for full management.
Isolation model : Each API call runs in its own lightweight Hyper‑V VM vs. all containers share a single VM.
Feature completeness : Preview‑stage, basic functionality vs. full feature set (Compose, GUI, Scout security scanning).
Docker Compose support : Not available in the preview vs. supported.
GUI : CLI‑only vs. graphical interface provided.
Performance Benchmarks
Cold start (nginx) : 180 ms (WSL Containers) vs. 2.1 s (Docker Desktop).
Hot start : 50 ms vs. 800 ms.
Node build (1000 modules) : 12.3 s vs. 15.8 s.
Cross‑OS file read (1 GB) : 8.2 s vs. 8.5 s.
The faster start‑up times stem from reusing the existing WSL 2 kernel instead of launching a separate Docker VM. File‑system performance is comparable because both solutions rely on the same 9P file‑system layer.
Current Limitations (Public Preview)
No Docker Compose support – multi‑container orchestration via compose.yml is unavailable.
CLI‑only interface – no graphical dashboard.
Documentation is still sparse and occasional bugs may appear.
Requires Windows 11 (or Windows 10 22H2+ with Hyper‑V); older Windows versions cannot use the feature.
Conclusion
WSL Containers adds a native container layer on top of WSL 2, allowing Linux containers to run on Windows without installing Docker or paying for a license. The command syntax is almost identical to Docker, resulting in low migration cost. Teams that rely heavily on Docker Compose, a GUI, or advanced enterprise features should continue using Docker Desktop until WSL Containers mature further.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ubuntu
Focused on Ubuntu/Linux tech sharing, offering the latest news, practical tools, beginner tutorials, and problem solutions. Connecting open-source enthusiasts to build a Linux learning community. Join our QQ group or channel for discussion!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
