π³ 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
