DEV Community

Cover image for From Linux and macOS to WSL: Setting Up a Dev Environment on Windows
Karthik Natarajan
Karthik Natarajan

Posted on

From Linux and macOS to WSL: Setting Up a Dev Environment on Windows

Introduction

Coming from use of Linux distributions and macOS, I was not familiar with PowerShell commands or Windows management. I had a Windows desktop and wanted to use it without dual booting and extra partitions. I explored Windows Subsystem for Linux (WSL).

Why I Chose WSL

  • No dual boot. I wanted to avoid complexity and resource overhead of a second Linux installation.
  • Native Linux tools on Windows. WSL allows running a Linux environment on Windows.
  • File system integration. WSL mounts Windows drives under /mnt.

Setting Up WSL with Ubuntu

  • Installation: I set up WSL with Ubuntu using Microsoft Store.
  • Drive mapping: In WSL, under /mnt, I accessed Windows drives.

Working with Cursor and Centralized Projects

  • Editor setup: I use Cursor and point it to Ubuntu WSL filesystem.
  • Cloud syncing: I placed projects in a OneDrive folder to switch machines. My WSL environment syncs via OneDrive.

Integrating Docker Desktop with WSL

An aspect of dev work is Docker. Here is how I set up Docker Desktop for use with WSL.

Enabling WSL 2 and Docker Integration

  • Set WSL 2 as default backend:
  wsl --set-default-version 2
Enter fullscreen mode Exit fullscreen mode
  • Configure Docker Desktop:
    • Open Docker Desktop and go to Settings > General. Enable Use WSL 2 based engine.
    • In Settings > Resources > WSL Integration, enable integration for your WSL distributions. Use the toggle next to the distribution.
    • Select Apply & Restart.
Setting Where to Find It Purpose
WSL 2 Backend Settings > General Linux compatibility
WSL Integration Settings > Resources > WSL Integration Docker commands accessible in WSL distros

Docker Group Permissions

If you have permission issues with Docker, make sure your WSL user is in the docker group.

Steps:

  1. Open Ubuntu terminal in WSL.
  2. Run:

    sudo usermod -aG docker $USER
    
  3. Log out and back in or run:

    newgrp docker
    
  4. Check permissions:

    ls -l /var/run/docker.sock
    

    The group owner should be docker and group should have write permissions.

This allows Docker commands without sudo.

Conclusion

This approach let me work in a Linux environment on Windows, with Docker support.

Top comments (0)