Lando on WSL2

Let me start with saying I think Lando is pretty awesome. A big thank you to all those involved in creating it and thereby making container based development not completely insane. Now that we've cleared that up, this post is hopefully timely, but also hopefully in a few months or so will no longer be needed. Let me explain why…

Right now if you want to use Lando in your WSL2 environment then there is documentation for that, but you should ignore it (in my opinion). The problem is Hyperdrive is out of date and being rebuilt (though it will be awesome when it's done). Accordingly, if you follow their current docs you end up with an older version of Lando and Docker. And that's never great. It also means you have to use Ubuntu 18.04 as your Linux flavour in your WSL2 instance instead of the more common and more recent Ubuntu 20.04 / 22.04.

So instead of following the Lando docs, I would recommend doing the following:

Initial Installing of Stuff

  • If you have never installed WSL2 before on your system, then simply run this command wsl --install from your Windows command line (running as an administrator).
  • The above command will magically setup and install everything for you -- it installs WSL2 and Ubuntu from the Microsoft Store.
  • If you have previously setup WSL2, be sure to uninstall and reinstall the Ubuntu app, or whatever flavour of Linux you installed previously.
  • Next up, install NodeJS via nvm as per Microsoft's recommendations.
  • Now you need to install Docker for Ubuntu.
  • You'll probably find you need to tweak your user permissions for Docker. Just follow the instructions in this Github issue and you're all set, or just run these commands in this order:
    • sudo groupadd docker
    • sudo usermod -aG docker yourLinuxUserName
    • newgrp docker
  • Lastly you need to get and install the latest stable Lando. Please follow their Linux (Debian) installation instructions.

Everything you need should now be installed and almost ready to go. If you want to check that things are looking good you can actually still try out Hyperdrive (v0.6.1). Just follow the installation instructions – which really just means copy and paste the installation command into your command line.

IMPORTANT → Do not actually complete the installation with Hyperdrive, just let it run the tests to make sure it shows you have everything you need installed then exit. Also, ignore the note to downgrade your version of Node.

Fire up Lando (aka, your first container)

We're already almost there and ready to go. We just need to do a few more things…

  • Run the lando init command in a folder somewhere in your WSL2 user profile to get things going (including starting Docker). Ideally this folder is where you want to launch a project / app / website.
  • Tweak your .lando.yml file as need be for your project (see Lando Docs to learn all about that if you haven't done that already).
  • Then run lando start to fire up your contains and such. This will also generate the main Lando SSL cert, as well as one for your project.
  • Add the Lando CA to your Windows certificate store, as per the Lando security docs.
    • NOTE: keep in mind though that the path will be to your cert in your WSL instance not to a Windows path like it shows in the security docs linked above.
    • So using Powershell or Command Prompt you'll just need to run the command suggested in the docs with the revised path. Something like this:
    • certutil -addstore -f "ROOT" \\wsl.localhost\Ubuntu\home\WSL-USER-NAME\.lando\certs\
  • If you are a Firefox user (like I am), then you need to enable Firefox use the Windows certificate store. To allow Firefox to use the operating system's certificate store, the security.enterprise_roots.enabled setting must be set to true.
    • To change that setting type about:config in the address bar and then you should be able to figure it out from there… :)

All done! Now sit back and enjoy the latest Lando and Docker all within your WSL2. Hooray!

You very likely will get a warning about "Using an unsupported version of DOCKER ENGINE". This shouldn't be an issue. And to get the cool "Boomshakalaka" message you should see, you need to quickly hack the Lando config file ~/.lando/config.yml by adding this to it:

        max: 25.10.99

Photo by Casey Horner on Unsplash

© 2023 Creative Logic Tech Solutions.