Docker unable to run with WSL

Docker unable to run with WSL  

  By: Gino on May 2, 2022, 10:40 a.m.

I'm following the algorithm tutorial, and get stuck with the Docker installation. So basically, Docker fails to start running:

When I run:

sudo service docker start

It outputs this:

 * Starting Docker: docker      [ OK ]

Looks okay, but then when I check if it's running, with sudo service docker status, I get:

* Docker is not running

Also, when I try to run sudo docker run hello-world, it gives:

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.

I'm running Ubuntu 20.04 on WSL.

Re: Docker unable to run with WSL  

  By: Gino on May 2, 2022, 10:41 a.m.

So as it turned out I was running WSL version 1, where version 2 is needed to be compatible with Docker Engine. You can check what version you're running, with wsl -l -v in Powershell, and then set it to WSL2 if needed:

wsl --set-version $yourLinuxInstall 2

And replace $yourLinuxInstall by the name of the linux installation.