Upgrading from WSL1 to WSL2 in Ubuntu and Docker

Thomas Dubiel
2 min readMar 28, 2021

--

Recently when attempting to deploy a Rails app using Docker and Kubernetes, I came upon an error early on, telling me that Docker is incompatible with Windows Subsystem for Linux 1, and I need to upgrade to Windows Subsystem for Linux 2. I run the following command in PowerShell to see which versions of WSL are being used by with applications:

PS C:\Users\user> wsl.exe -l -v
NAME STATE VERSION
* Ubuntu Running 1
docker-desktop Running 1
docker-desktop-data Running 1

In this case, both Ubuntu and Docker are running WSL1. To upgrade Ubuntu to to WSL2, we will follow the template:

wsl --set-version <distro-name> 2

So, in this case, we would want to run:

wsl --set-version Ubuntu 2

And now when we run

PS C:\Users\user> wsl.exe -l -v

We get

NAME STATE VERSION
* Ubuntu Running 2
docker-desktop Running 1
docker-desktop-data Running 1

This is a great start! It seems that our Linux system is running WSL2, and now we must configure Docker to use WSL2 as default. We can restart our system and start Docker Desktop and navigate to Settings > Resources > WSL Integration.

Above I have it applied already, but you will check Use the WSL 2 based engine and click Apply and Restart.

Upon restarting, open your PowerShell terminal and enter the following to check for WSL versions:

PS C:\Users\user> wsl.exe -l -v
NAME STATE VERSION
* Ubuntu Running 2
docker-desktop Running 2
docker-desktop-data Running 2

And you will have both Ubuntu and Docker running WSL2!

--

--

Thomas Dubiel
Thomas Dubiel

No responses yet