Resolved: Docker Not Starting with WSL2 - Here's the Fix
Recently, I encountered an issue where Docker Desktop wasn’t starting properly on my Windows machine despite WSL2 being installed. After spending a good amount of time debugging and researching, I found the root cause and resolved it. I'm sharing this here in hopes that it might help someone else facing the same issue.
Problem: Docker Desktop was failing to start and showed errors related to WSL2 or Hyper-V, such as:
checking if isocache exists: CreateFile \\wsl$\docker-desktop-data\isocache\: The network name cannot be found.
OR
running WSL command wsl.exe --mount --bare --vhd <path-to-vhdx>: ...
The usage help output is shown instead of execution.
Despite having WSL2 installed, Docker remained stuck or threw exceptions.
Root Cause: WSL2 was installed on the machine, but its required Windows features were not enabled.
Resolution Steps:
Here is the step-by-step guide to fix this:
✅ 1. Check if Virtualization is Enabled
Open Task Manager > Performance Tab > CPU
Ensure that Virtualization: Enabled is shown
If not, enable virtualization from BIOS
✅ 2. Check WSL Version
Run this command in PowerShell:
wsl --list --verbose
This will show if WSL2 is set for your distributions.
If WSL is not available or not working correctly, continue below.
✅ 3. Enable Required Windows Features
Run PowerShell as Administrator and execute:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Then restart your machine.
✅ 4. Uninstall Docker Completely (if already installed and stuck)
If Docker Desktop is stuck or misconfigured:
Uninstall Docker from Settings > Apps
Open PowerShell as Administrator and stop all Docker services:
Stop-Service com.docker.service
wsl --shutdown
Remove Docker-related files:
Remove-Item -Recurse -Force "$env:ProgramData\Docker"
Remove-Item -Recurse -Force "$env:AppData\Docker"Remove-Item -Recurse -Force "$env:LocalAppData\Docker"Remove-Item -Recurse -Force "$env:LocalAppData\DockerDesktop"
Restart your machine
✅ 5. Reinstall Docker
Download the latest Docker Desktop from: https://www.docker.com/products/docker-desktop
Install it, and during installation, choose to use WSL2 backend
After installation, Docker should start properly in Linux container mode.
Conclusion: If you have WSL2 installed but Docker isn't working, don't forget to enable the VirtualMachinePlatform and WSL features manually. A simple restart after that can get things back on track.
Comments
Post a Comment