WSL With Docker Could Not Be Found

This guide addresses the problem of Docker command not being found in a WSL 1 distribution by converting it to WSL 2 and enabling integration in Docker Desktop settings.

1. Problem

1
2
3
4
5
6
$ docker

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.

2. Solution

Run in cmd.exe

1
2
3
> wsl --list --verbose
  NAME             STATE           VERSION
  Ubuntu           Running         1

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

1
2
3
4
> wsl --set-version Ubuntu 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.

Also you need to go to the docker desktop settings, and enable integration with your distro in “Resources -> WSL Integration”.

3. Reference

使用 Hugo 构建
主题 StackJimmy 设计