Ubuntu WSL with docker could not be found

The command $ docker could not be found in this WSL 1 distro. We recommend to convert this distro to WSL 2 and activate the WSL integration in Docker Desktop settings.

See https://docs.docker.com/docker-for-windows/wsl/ for details.

Not able to change to WSL2 and not able to install docker:

docker wls


Solution 1:

You need to go to the docker desktop settings, and enable integration with your distro in "Resources -> WSL Integration".

enter image description here

Solution 2:

Assuming you already have wsl 2 in your system, run powershell as admin:

run wsl --list --verbose which will give you a list of your wsl running processes:

> wsl --list --verbose
  NAME                   STATE           VERSION
  Ubuntu-20.04           Running         1

Then to switch it with wsl --set-version <your proc> 2:

> wsl --set-version Ubuntu-20.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.