DEV Community

Cover image for πŸš€ Mastering WSL 2 and Docker on Windows: What I Learned, Real-World Use Cases, and Interview Prep
Pranto Mollick
Pranto Mollick

Posted on

πŸš€ Mastering WSL 2 and Docker on Windows: What I Learned, Real-World Use Cases, and Interview Prep

As a Windows user diving into modern development workflows, I recently explored WSL 2 (Windows Subsystem for Linux) and integrated it with Docker Desktop β€” and it was a game-changer!

In this post, I’ll break down:

  • βœ… What I learned from installing and configuring WSL 2
  • 🌍 How these skills apply in real-world development
  • 🎯 Interview questions I’m now prepared to answer

βœ… What I Learned

WSL 2 is a tool that allows you to run a real Linux kernel inside Windows, making it ideal for local development, especially when paired with Docker.

Here's what I learned step-by-step:

  1. Check System Requirements
  • Windows 10 (build 1903+) or Windows 11 (WSL 2 built-in)
  1. Install WSL 2 (Automatically or Manually)
  • PowerShell command:

     wsl --install
    
  • Manual alternative: enable features via DISM, install the Linux kernel update package, and set default version to 2.

  1. Install a Linux distribution (e.g., Ubuntu)
  • Via Microsoft Store β†’ Set it up with username/password
  1. Verify Installation
  • Run:

     wsl --list --verbose
    
  1. Install Docker Desktop
  • During installation, enable WSL 2 integration
  • Connect Docker to your Linux distro in Docker Settings

This entire setup creates a powerful hybrid environment: Windows + Linux + Docker β€” right on your desktop.


πŸ› οΈ Services I Can Offer (Freelancer or Team Contributor)

Now that I understand this system deeply, I can offer real-world tech services like:

πŸ’Ό Service Description
WSL 2 & Docker Setup Help devs or businesses set up WSL 2 and Docker Desktop on Windows
Local Dev Environment Build Linux-based dev environments for Laravel, Django, Node.js, etc.
Docker Containerization Dockerize apps and teach others how to use Docker on Windows
DevOps Assistant Assist with Linux + Docker pipelines, CI/CD, and local test environments
Troubleshooting Support Solve Docker/WSL issues that Windows users frequently face

These services are in demand on remote job boards.


🌍 Real-World Use Cases

Here’s how this knowledge applies in real-life projects:

Use Case How It Works
πŸ§‘β€πŸ’» Full-Stack Web Dev Run Linux-only tools (like Nginx, Redis, PHP) on Windows via WSL
🐳 Container Dev Build and test Docker images before deploying to cloud (AWS/GCP)
🐍 Python/ML Projects Use Jupyter, TensorFlow, and PyTorch inside Linux via WSL
πŸ§ͺ CI/CD Testing Simulate Linux pipelines locally with Docker containers
πŸš€ Dev Workflow Boost No need for dual-booting or switching to Linux β€” best of both worlds

🎯 Interview Questions You Now Ready For

These are the kinds of questions that can come up in DevOps, Backend, or Full-Stack roles:

πŸ”Ή WSL 2 Focused

  • What is WSL 2 and how does it differ from WSL 1?
  • How do you manage multiple Linux distros on WSL?
  • What are the limitations of WSL 2?

πŸ”Ή Docker with WSL 2

  • Why is WSL 2 preferred for Docker Desktop on Windows?
  • How does Docker Desktop integrate with WSL?
  • How do you troubleshoot Docker-Windows-WSL issues?

πŸ”Ή General System Setup

  • How do you set up a dev environment for Linux-based applications on Windows?
  • What PowerShell commands are used to enable WSL features?

πŸ”Ή WSL 2 Related

1. What is WSL and how is WSL 2 different from WSL 1?
Think of WSL like a translator who helps Windows speak Linux.

  • WSL 1 is like Google Translate β€” it converts Linux commands into Windows language, but it’s not perfect.

  • WSL 2 is like hiring a native Linux speaker (a full Linux kernel!) and giving them their own room inside your Windows PC.

In short:
WSL 1 fakes Linux, WSL 2 runs real Linux inside a small virtual machine β€” faster, more powerful, and closer to real Linux.

**2. How do you install and configure WSL2 on Windows?
just open PowerShell as Admin and Run:


wsl --install
Enter fullscreen mode Exit fullscreen mode

This will:

  • Enable necessary windows features
  • Install Ubuntu
  • Set WSL 2 as the default

It’s like ordering a Linux room service β€” it arrives ready to use!
If it doesn’t work, you can do it manually using a few commands (enabling features, installing Linux kernel, restarting, and downloading a distro like Ubuntu).

3. Can you run Linux-only tools on Windows using WSL 2? How?

Yes, and it’s magical! ✨
magine you want to cook a Bengali recipe but you only have a Western kitchen. WSL 2 brings a real Bengali kitchen inside your Western home. You can now:

  • Run Bash
  • Use apt to install packages
  • Use Linux web servers like Apache
  • Compile code using GCC
  • Run Python, Node, PHP with native linux behaviour. All without leaving windows.

4. What are the limitations of WSL 2?
Every superhero has a weakness πŸ’”

  • It uses a lightweight VM in the background β†’ more RAM
  • Slower file access between Windows ↔ Linux (use /home, avoid /mnt/c )
  • No full support for USB devices or kernel modules
  • Some system services (like systemd) needed workarounds (fixed in latest WSL)

Analogy:
You invited Linux to your house (Windows), but you can’t let them use your Wi-Fi (USB access) or let them renovate your house (low-level hardware stuff).

5. How do you manage multiple Linux distros in WSL?

You can install many flavors of Linux: Ubuntu, Debian, Kali, etc.

πŸ”§ Check list:

wsl --list --verbose
Enter fullscreen mode Exit fullscreen mode

πŸ” Set default:

wsl --set-default Ubuntu
Enter fullscreen mode Exit fullscreen mode

πŸ”„ Change version:

wsl --set-version Ubuntu 2
Enter fullscreen mode Exit fullscreen mode

πŸ”Ή Docker + WSL 2 Integration

6. Why is WSL 2 preferred for Docker on Windows?
Docker runs best on Linux, but Windows doesn’t speak Linux natively.
🧠 With WSL 2:

  • You get a real Linux kernel
  • Docker can run natively, not emulated
  • It’s faster, lighter, and more efficient

Analogy:
It’s like building a pool (Docker) β€” it works way better on real ground (WSL 2) than on a floating platform (Windows VM).

7. What is Docker Desktop, and how does it use WSL 2?
Docker Desktop is a GUI tool that makes it easy to manage Docker on Windows. With WSL 2:

  • Docker doesn’t need a big VM anymore
  • It installs inside your WSL distro
  • It runs containers as if you're on real Linux

8. How do you troubleshoot Docker not starting on Windows with WSL 2?

βœ… Check WSL 2 is installed:

wsl --list --verbose
Enter fullscreen mode Exit fullscreen mode

βœ… Restart Docker Desktop
βœ… Ensure virtualization is enabled in BIOS
βœ… Check WSL Integration is turned on in Docker Settings
βœ… Run PowerShell as Admin and update kernel if needed

9. What are some real-world advantages of using Docker + WSL 2 for development?

  • You can test Linux apps on Windows
  • Use Docker without full VMs β†’ faster builds
  • No more dual-booting or cloud deployments just to test things
  • Easily build containers for Laravel, Django, React, etc.

Example:
You’re building a Laravel site. Run it in a Docker container in WSL 2, test it, and then push it to production β€” all from your Windows laptop!

10. How do you configure Docker to use a specific WSL distro?

Open Docker Desktop β†’
Settings β†’ Resources β†’ WSL Integration β†’ Enable for your preferred distro (e.g., Ubuntu).

Now Docker knows which kitchen (distro) to use when cooking up containers.

πŸ”Ή General System Knowledge

11. Explain the role of virtualization in WSL 2.
WSL 2 uses a tiny virtual machine to run a real Linux kernel.
πŸ” This VM is lightweight, fast, and auto-managed by Windows β€” you won’t even notice it’s there.
Analogy:
It’s like running a guest Linux computer inside your Windows PC β€” but it shares your home’s (system’s) electricity and water (RAM and CPU) without making noise.

12. Have you used PowerShell for administrative setup? Give examples.
Yes! PowerShell is like the control room of Windows. I’ve used it for:

  • Installing WSL features:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Enter fullscreen mode Exit fullscreen mode
  • Setting default WSL version:
wsl --set-default-version 2
Enter fullscreen mode Exit fullscreen mode
  • Installing Docker
  • Automating System Task

13. How would you set up a development environment for a Linux-based application on Windows?

Let’s say you want to build a Django web app. Here’s how:

  • Install WSL 2 and Ubuntu
  • Update and install dependencies:
sudo apt update && sudo apt install python3-pip python3-venv
Enter fullscreen mode Exit fullscreen mode
  • Create a virtual environment and install Django
  • Install Docker Desktop with WSL 2 integration
  • Dockerize your Django app

Now you can code, test, and deploy like you’re on a Linux server β€” from your Windows machine.

πŸ’‘ When you master WSL 2 and Docker together, you unlock a hybrid development world: Linux power, Windows productivity, and cloud-readiness β€” all from your laptop.

Top comments (0)