Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 701
suki Avatar asked Aug 20 '20 03:08

suki


People also ask

Can I run Docker in WSL Ubuntu?

However, since WSL 2 now runs on a Linux kernel with full system call capacity, Docker can fully run in WSL 2. This means that Linux containers can run natively without emulation, resulting in better performance and interoperability between your Windows and Linux tools.


4 Answers

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

enter image description here

like image 83
pushStack Avatar answered Oct 06 '22 18:10

pushStack


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.
like image 36
Joey Baruch Avatar answered Oct 06 '22 19:10

Joey Baruch


I stuck with this error after remove Ubuntu 18.04 and install the 20.04.

Even with the WSL 2 enabled, I still face this error.

This is what works for me, go the Settings --> resource and toggle the "Ubuntu" then the error disappear :)

enter image description here

like image 12
raynus Avatar answered Oct 06 '22 18:10

raynus


My problem seems like it's the same, despite the integration WSL is already enabled since installation.

In the windows shell:

> wsl docker --version

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

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

An option to resolve this problem is reinstalling Docker Desktop (https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/configure-docker-daemon#how-to-uninstall-docker), but don't need to do this.

The steps below work for me (I found at https://github.com/docker/for-win/issues/7039).

Open windows shell (maybe as admin), and run:

> wsl -t docker-desktop
> wsl --shutdown
> wsl --unregister docker-desktop

Then go to windows services, stop the Docker Desktop Service, OR to do this running the command in windows shell as admin:

> Stop-Service -Name "com.docker.service"

And finally, restart the Docker Desktop App.

Test in the windows shell:

> wsl docker --version
Docker version 20.10.2, build 2291f61
like image 82
Fabrício Pereira Avatar answered Oct 06 '22 18:10

Fabrício Pereira