Docker WSL 2 Windows
Docker is an open-source application container engine that packages an app with its dependencies into a portable container that runs anywhere supported. Containers are sandboxed and isolated from each other with very low overhead. This note runs Docker on Windows on top of WSL 2, from WSL setup through Docker installed and running for the first time. For commands, configuration, and Compose once it is installed, see Docker Commands, Configuration, and Compose; to build your own image, see How to Write a Dockerfile.
Installing WSL
WSL (Windows Subsystem for Linux) runs a Linux environment on Windows and is the best foundation for Docker on Windows.The modern
wsl --install automatically enables the required Windows features and installs the default distro, so manual feature toggling is usually unnecessary. The manual step 1 below is for fine-grained control or when auto-install fails. WSL 2 only needs “Virtual Machine Platform” and “Windows Subsystem for Linux”; Hyper-V and Windows Hypervisor Platform are not required (and Hyper-V is absent on Windows Home).Enable features (optional, if auto-install fails)
Control Panel → Programs → Turn Windows features on or off, check:
- Virtual Machine Platform (required)
- Windows Subsystem for Linux (required)
- Hyper-V, Windows Hypervisor Platform (optional, not required for WSL 2)
Install WSL
Open PowerShell or Command Prompt as administrator and run:This enables the required features and installs the default Linux distro (Ubuntu). Restart afterwards.
Set up the Linux user
On first launch the new distro opens a console, waits for files to extract (faster afterwards), and prompts you to create a username and password.
Start as root (if no user was set in step 3)
If
wsl --install did not prompt for a username/password, enter as root first, then create an account manually:Tune WSL 2 resources (optional)
Edit Apply with
C:\Users\<your-username>\.wslconfig to cap WSL 2 memory and processors. The [wsl2] section header is mandatory, or the settings are ignored:wsl --shutdown to restart WSL. Docker’s CPU and memory on the WSL 2 backend are controlled by this file (not the Docker Desktop GUI); see Performance settings.Installing Docker
Use Docker Desktop with the WSL 2 engine on Windows.Install Docker Desktop
Download the installer from Docker and follow the prompts; mind the system requirements.
Enable the WSL 2 engine and integration
Settings (top-right gear) → General, check “Use the WSL 2 based engine”; Resources → WSL Integration, select the distros to enable Docker integration for, then Apply & Restart.
Next steps
Once installed, continue here. Usage and configuration:- Core concepts: Image, Container, Volume, and the two interfaces.
- CLI commands: what you use every day.
- Docker Hub: where images come from and how to trust them.
- Performance settings: WSL 2 backend resources and daemon.json.
- Where data lives: volume, bind mount, tmpfs, and no mount.
- Docker Compose: bring up many containers at once.
- Basics and building from scratch, instructions, Python app, choosing images, layer cache and best practices.
Links
- Docker docs: docs.docker.com
- WSL docs: learn.microsoft.com/windows/wsl