Installing Docker Desktop for Windows Home and WSL2
How-to install Docker Desktop Edge for Windows Home and WSL2 to work with Visual Studio Code
So, when I was writing about WordPress and Docker Composer, a new version of Docker Desktop was released: it’s finally compatible with Windows Home and WSL2 — without the need of a full, native Hyper-V support. Why should you care? It would have been saved hours of work in a company I worked for. Bet it, there still are companies which use budget laptops and some developers have a pre-installed version of Microsoft’s operating system. Finally, Docker provides a solution for all of them.
Docker Desktop Edge
Getting Docker Desktop has never been easier. You know, computers are usually sold with “limited” or family version of Windows for many reasons: they implement poor hardware to lower their prices and most of the customers don’t actually need a developing or a gaming machine. OK, but what about programmers forced to adopt a BYOD policy for limited times? Right know I have only two budget laptops, one with Windows Home and another with Ubuntu, then I couldn’t work on both in the same way before.
Linux let me get a copy of Docker CE (Community Edition) for free, but Docker Desktop didn’t work under Windows Home: it needed BIOS virtualization support, as well as a full working Hyper-V instance, so it could have been installed only on a Pro version. It doesn’t matter if you were an Insider Preview member or not. Finally on March, 5th has been released a new version of the hypervisor that supports less ambitious devices; but you also need Windows Insider Preview 19040 or higher to install and run it.
If you remember, once Docker had a software which supported VirtualBox instead of Hyper-V — called Docker Toolbox. Then the rise of Docker Desktop made it obsolete and no more supported: yet another reason why a new version for Windows Home is relevant. Let’s download the official preview of Docker Desktop Edge to get started; being an executable, I don’t think that you need further instructions here. The fun starts when you’ll get it up and running, because we have at least two things to play with WSL2.
WSL (Windows Subsystem for Linux) 2
WSL (Windows Subsystem for Linux) was one of the new features that convinced me to come back to Windows. I used Linux alone for a decade before it happens: my recent switch to Ubuntu Budgie was caused by the lack of support for Docker Desktop under Windows Home. You can install some alternative distributions too, such as Debian and openSUSE, but I’ll work with Ubuntu here. If you’re an Insider, maybe your WSL setup is still based on the first version of the subsystem, so you need to update it to the newer WSL2.
> wsl -l -v
> wsl --set-version Ubuntu-19.10 2
Change the name accordingly. These short PowerShell commands let you see a full list of WSL-based distributions installed and print their version: in my case, there’s just Ubuntu 19.10 that I wanted to update. You should do this, because WSL2 introduced new features you need to get Docker Desktop Edge running there. Wait… above I spoke about Hyper-V and VirtualBox support, now what the hell am I saying? What does WSL have to do with it? Thanks for asking. You’ll be enthusiast to associate Visual Studio Code too.
Starting with WSL2, Microsoft asks for a manual update of the Linux kernel: as long as you’re an Insider, you can download the required executable from the official archive. Of course, you need to grant administration privileges to continue; right now,¹ you can also upgrade to Ubuntu 20.04 LTS by running
sudo do-release-upgrade -d in the subsystem shell. I hade some issues during the upgrading process, although I waited for the stable release. Be careful, because it should be definitely done after the main kernel update.
Visual Studio Code
One of the most annoying issues working with WSL in the past was how-to sync a remote repository on Linux, but modifying its sources on Windows. I used to do all the versioning via BASH, but I worked in Atom under Windows Home to update my projects’ code. I recently switched to Visual Studio Code on Ubuntu too, because I found it has grown faster than I expected and it really rocks if you have an hybrid ecosystem: thanks to an official WSL extension for the editor you can now sync the two operating systems by just…
$ code .
…a single piece of code from the VM. This will open a new Visual Studio Code instance on Windows, letting you edit your code managed by WSL2 and [eventually] secured in a Docker Desktop container. Of corse, the last works also on Windows Pro devices: if you like WSL, I suggest you to install that extension even if you don’t plan to use it with Docker. But, if you do, there are more improvements and I’ll speak about them in the next few days. This is by far the most advanced solution I’ve ever had on a personal laptop to date.
Installing Docker Desktop, you’ll be asked for a Git for Windows setup as a requirement you can solve with the official 64-bit installer and a preferred editor: by default, it selects Vim, but Visual Studio Code is among the choices. Be sure it’s already installed and configured in your
PATH. This is yet another option to better integrate the two services; Microsoft gave a spin to its open source division and took care of options like these. Atom is a great alternative I’d suggest you to choose too, if you’re looking for something a bit different.
¹EDIT: Canonical announced an optimized version of Ubuntu 20.04 LTS for WSL2. (2020/05/31)
I’ll share more personal experiences with Docker, WSL2, and Visual Studio Code in the near future. What I spoke of above is just the actual way to get them running together, explained directly by who released Docker Desktop Edge. Being a preview, it couldn’t be implemented in production — and I strongly recommend you to exclude it. I’m having fun with this, because I’m only playing with its features to be among the first to learn how-to get different platform in sync since I guess it will shortly become part of the stack.