Hey everyone! Following up on my post on setting up a Docker and Kubernetes dev environment in WSL 1, I thought I’d share the process I went through for getting Docker installed now that WSL 2 is out and about! So far, switching to WSL 2 has been a HUGE improvement for me, the performance bumps were definitely not overstated :)
Step 1: Get WSL 2
Currently, WSL 2 is available to Windows insiders in the fast ring
Once you’ve setup the insider program with the above settings, you should be able to check for updates and get a build that supports WSL 2 (18917 or higher).
After you’re on a correct build, open up a PowerShell admin window and run:
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform
After that, restart your computer (I know, I know…). Once you boot back up, you should be set to convert your WSL installation to WSL 2 with this command (replace <Distro> with the Linux distro you have installed) in PowerShell:
wsl --set-version <Distro> 2
For slightly more detailed instructions, you can refer to the official docs here!
Step 2: Install Docker
To install Docker, just open up a WSL 2 window (open PowerShell, or Windows Terminal and type
wsl ) and run the following commands:
$ sudo apt-get remove docker docker-engine docker.io containerd runc $ sudo apt-get update$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common$ 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"$ sudo gpasswd -a $USER docker
Lastly, since WSL 2 doesn’t use systemd, Docker won’t be able to start on it’s own. To start it, run:
$ sudo service docker start
That’s it! You should now be able to interact with the Docker daemon fully within WSL!