Local development with WSL2, Node, and Docker

Local development with WSL2, Node, and Docker

some time ago I wrote an article on LinkedIn with my findings on how to create a local development environment under Windows. since then, a lot has changed, and yet something hasn't: I'm still running Windows (now version 11).

anyway, since I've upgraded my setup, I think it's time to look back on that piece and retrace my steps, updating it for the modern tech we're all using -- aren't we?

if you're also on this OS, follow these steps and you'll be running Ubuntu, with pretty much everything you need to mirror your favourite webhost, in a tight and lean package.

so let's dive in.

1. enable WSL2 on Windows 11

open PowerShell as Administrator and enable WSL:

by the way, remember to update. and reboot.

if WSL is already installed, ensure it's updated to WSL2:

then set WSL2 as the default version:

what's the difference between WSL versions 1 and 2? well, that's a great question, rhetorical person. you can find out more at https://aka.ms/wsl2, but here's a nifty chart:

courtesy of Microsoft.

2. install Ubuntu LTS (Long Term Service)

you can find several different Ubuntu versions in the Windows Store. for the purpose of this solution, grab the generic one, which will keep you up to date with current and future major versions.

but can you find Windows in the Ubuntu Store? 🤪

keep in mind that the first time you launch it, setting up will take a few minutes. meanwhile, pick a username and password once prompted.

so friendly!

next, update Ubuntu via its terminal:

this is a good command to run from time to time, by the way.

another great tool is Windows Terminal, which will group all your favourite command lines in one, tab-separated place.

3. install NVM (Node Version Manager)

each project runs a different Node.js version. in order to keep up with that, it's nice to have a tool to assist you in swapping versions. that's where NVM comes into play.

run the following command:

note: the /v0.40.2/ part is the latest version at the time of writing. double-check periodically at the NVM GitHub repo -- look for the readme with instructions.

next, close and reopen the terminal, or run:

then check if NVM is working with:

which should return the same value as the version in the URL -- in this case, 0.40.2.

then install Node.js v22.14.0 LTS (the latest one) using NVM:

use it with:

you should see a message such as:

npm being the Node Package Manager, which installs Node.js dependencies.

if by any chance you don't get the default set, you can set it yourself with:

and verify Node.js:

if you downloaded Windows Terminal, you can open Ubuntu under WSL2 with the down arrow like so:

there is really only one choice as far as this guide is concerned.

3. install Docker

along with NVM, Docker will assist you in creating several different containers for your projects, each with a different stack.

start with:

then add your user to the docker group:

next, you'll choose either DDEV or Lando for your projects. I've already published a guide for the latter, which you can check out here: https://www.linkedin.com/pulse/drupal-11-local-multisite-ddev-luciano-cossich-sales-hkfgf/ (and as a bonus, it will assist you with a Drupal multisite installation.)

and that's it for this guide. happy coding!

Ivan Zugec

Senior Drupal Developer and Consultant

4mo

Do one on setting up Drupal CMS and DDEV, I get a lot of comments on my videos telling me how hard it is to set up Drupal CMS on Windows via DDEV.

To view or add a comment, sign in

Others also viewed

Explore topics