Dear Reader,
About five months ago I started using Lando. I have never been a Docker fan. I know Docker is useful, but for most things I work on it just seemed to be one additional layer on top of everything else I’ve got to build. Then a friend I was working with at the time introduced me to Lando. Lando seemed almost perfect.
- It was easy to spin up and down
- It supported PHP, WordPress, Drupal, and Composer out of the box
- It was easily extensible
Honestly, the only downside was that on Windows 10, it ran in Windows, not in WSL. On Windows all my development takes place inside WSL. Until I started working a contract that required it, I didn’t even have Git or PHP installed on Windows, only in WSL.
Then WSL2 hit and everything changed. Docker released a new version that would run inside of WSL2 and would take advantage of the WSL2 Linux kernel when running in Windows. I was beginning to see the light at the end of the tunnel.
Still, as with everything in tech, there were hurdles to overcome. This blog post does not delve into the WHY things work the way they do; honestly, in some cases, I do not know. This is designed to be a step-by-step guide to getting Lando and Docker up and running.
Also, where applicable, I have linked to the original posts where I got the information. Most of this info was borrowed from other sites but I had to piece things together to get everything working.
Step, the first: Install Docker
I am going to assume you already have already upgraded Windows 10 and have WSL2 installed and operational. You will need a Linux distribution. I chose Ubuntu because Cent OS isn’t available (grumble).
WARNING
If you have Docker Desktop installed on Windows 10, check the settings. If you have enabled WSL integration make SURE – I mean absolutely, positively SURE – that you do not integrate it with the distro you are going to be using Lando with. If that’s your default Distro then don’t check the “Enable integration with my default WSL distro” checkbox. Make sure the slider is not lit for the distro you will be using Lando with. Failure to do this will lead to hours of heartache and head-banging until you come back to this post, read it again from the top, and see this warning.
Ok, now that you either understood and heeded the warning above, or you ignored it thinking it doesn’t really apply to you, follow the instructions from https://dev.to/bartr/install-docker-on-windows-subsystem-for-linux-v2-ubuntu-5dl7 to get Docker up and running on your WSL2 distro.
For me, these were the commands I executed. Feel free to copy and paste them one command at a time. (They are the same ones from the blog post but without the comments.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | sudo apt-get update sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common libssl-dev libffi-dev git wget nano sudo groupadd docker sudo usermod -aG docker ${USER} curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list sudo apt-get update sudo apt-get upgrade -y sudo apt-get autoremove -y sudo apt-get install -y docker-ce containerd.io sudo apt-get install -y kubectl sudo curl -sSL https://github.com/docker/compose/releases/download/`curl -s https://github.com/docker/compose/tags | \ grep "compose/releases/tag" | sed -r 's|.*([0-9]+\.[0-9]+\.[0-9]+).*|\1|p' | head -n 1`/docker-compose-`uname -s`-`uname -m` \ -o /usr/local/bin/docker-compose && sudo chmod +x /usr/local/bin/docker-compose |
That got me almost there. right now, if you can run the following command and it works then you are golden.
docker run hello-world |
If that worked, you can proceed to Step, the Second.
However, if you get this error:
docker: Error response from daemon: cgroups: cannot found cgroup mount destination: unknown. |
Then you need one more step. Reading the thread https://github.com/docker/for-linux/issues/219, I found that Dinar-Dalvi posted this “temporary” fix. Execute these two commands in your WSL2 terminal.
1 2 | sudo mkdir /sys/fs/cgroup/systemd sudo mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd |
Now try Docker run hello-world again. It should work. If you’ve gotten this far, you are home free. The rest is pretty easy.
Step, the second: Install Lando
Ok, Lando’s install instructions are pretty dang simple. Go to the Lando Releases Page and grab the package for your distro from the latest version. Since I am using Ubuntu, I grabbed the .deb package. Then, following the instructions on the Lando Install Page I executed:
sudo dpkg -i lando-WHATEVER_I_DOWNLOADED.deb |
Yup, it’s that easy.
Step, the third: Spin up your first Lando
I work with WordPress a lot so my Lando Hello World was spinning up a WordPress site. The very easy to use Lando manual has a page for WordPress and to init a container for Lando with WordPress, all I need to do is follow these instructions.
$ lando init \ --source remote \ --remote-url https://wordpress.org/latest.tar.gz \ --recipe wordpress \ --webroot wordpress \ --name my-first-wordpress-app $ lando start |
BOOM!
Two minutes later I have a working WordPress site ready for my “Five Minute Install.”
Before you start the final WordPress install step, make sure you execute:
lando info |
Lando has already installed a DB for you and created a user. lando info
will give you the info you need to finish up the install and start developing your next great idea with Lando.
Step, the last: Wrap-up
If you are already a Docker aficionado and conversant with how to setup and maintain Docker containers, Lando, will be of little interest to you. However, if you are a developer who just wants to get a container spun up so they can work on a website (WordPress, Drupal, Laravel, whatever) it is a great tool and will fast become one of your regulars.
Until next time,
I <3 |<
=C=