🐳 Docker Installation & Setup on Windows with WSL2 — Complete Guide
Follow this step-by-step tutorial to get Docker running on Windows using WSL2, enabling a full Linux container environment seamlessly integrated with Windows.
⚙️ Step 1: Enable WSL2 on Windows
Open PowerShell as Administrator and run:
wsl --install
This installs the Windows Subsystem for Linux and Ubuntu (default). Then, restart your computer.
✅ After reboot, check WSL version:
wsl -l -v
Ensure Ubuntu is showing as Version 2.
🧩 Step 2: Install Docker Desktop for Windows
- Download Docker Desktop: https://www.docker.com/products/docker-desktop
- During setup, enable “Use WSL 2 based engine”
- After installation, open Docker Desktop. It should automatically create
docker-desktopanddocker-desktop-data. - Ensure Docker Desktop is running:
net start com.docker.service
(If already running, you’ll see confirmation)
🐧 Step 3: Open Ubuntu (WSL2)
Launch Ubuntu from Start Menu or PowerShell:
wsl -d Ubuntu-22.04
Now you’re inside a Linux environment on Windows.
🔍 Step 4: Verify Docker Connection
Run:
docker version
If you see both Client and Server information — success! You’re connected to the Docker Engine running in docker-desktop.
🚀 Step 5: Run Your First Container
Try the official test image:
docker run hello-world
It should display:
“Hello from Docker! Your installation appears to be working correctly.”
🌐 Step 6: Run an NGINX Web Server
Test with a real web app:
docker run -d -p 8080:80 nginx
Then open your browser at: http://localhost:8080
You’ll see the Nginx welcome page, confirming container networking works perfectly.
🧠 How Docker Works with WSL2
- docker-desktop → runs the Docker Engine
- docker-desktop-data → stores images, containers, and volumes
When you type docker in Ubuntu, the CLI talks to the Docker daemon through a local socket shared between WSL2 instances. This design gives you:
- Native Linux performance
- No need for VirtualBox or Hyper-V
- Seamless integration between Windows and Linux filesystems
✅ Quick Verification Checklist
| Task | Command | Status |
|---|---|---|
| Check WSL2 running | wsl -l -v |
✅ Ubuntu & docker-desktop |
| Check Docker service | net start com.docker.service |
✅ Running |
| Verify Docker Engine | docker version |
✅ Client + Server OK |
| Test container | docker run hello-world |
✅ Works |
| Run NGINX | docker run -d -p 8080:80 nginx |
✅ Webpage loads |
🎯 Conclusion
You now have:
- Docker running on Windows using WSL2
- Full Linux-based container environment
- Ability to build, run, and deploy containers directly from Ubuntu
Next steps:
- Build your own images with a
Dockerfile - Manage containers with
docker-compose - Use VS Code + Remote Containers for development
