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 (which I highly recommened) then there is documentation for that. The big problem though is right now Hyperdrive is out of date and being rebuilt (though it will be awesome when it's done). As such, if you follow the above 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.

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

Initial Installing of Stuff

  • Okay, actually you should start with the Lando recommened Prerequisites.
  • Now you should have a clean WSL2 instance and the Ubuntu / Ubuntu 20.04 app installed
  • 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.
  • Lastly you need to get the latest stable Lando. So 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.
    • NOTE: if you want to start Docker on WSL initial boot up then add "sudo service docker start" to wsl.conf
  • 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, you'll need to either copy over cert to your WFS (Windows files system) or change path to point to the cert which is actually in WSL2 the way we've set things up. I went with the latter to just keep everything in WSL.
  • 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 site back and enjoy the latest Lando and Docker all within your WSL2. Hooray!

Photo by Casey Horner on Unsplash

© 2022 Creative Logic Tech Solutions.