Docker not running on Ubuntu WSL due to error cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? [closed] Docker not running on Ubuntu WSL due to error cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? [closed] linux linux

Docker not running on Ubuntu WSL due to error cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? [closed]


I found your question, as I was trying to achieve the same. {I have updated my question as with the latest windows update, the process it's much more easier}

Using WSL2

You simply have to activate and use WSL2, I have to install Ubuntu 20.04 as the 18.04 wasn't connecting with Docker desktop. In the windows shell:

To check the WSL mode, run

wsl -l -v

To upgrade your existing Linux distro to v2, run:

wsl --set-version (distro name) 2

WSL Integration will be enabled on your default WSL distribution. To change your default WSL distro, run

wsl --set-default <distro name>

Then in docker you have to.

...use the WSL2 engineActivate WSL2

...access from your default WSL2enter image description here

Based on this article.A Linux Dev Environment on Windows with WSL 2, Docker DesktopAnd the docker docs.Docker Desktop WSL 2 backend

Below is valid only for WSL1

It seems that docker cannot run inside WSL. What they propose is to connect the WSL to your docker desktop running in windows: Setting Up Docker for Windows and WSL

In the docker forums they also refer to that solution: Cannot connect to the docker daemon

Hope that helps.


Go into PowerShell and type: docker context ls

Output:

NAME                DESCRIPTION                               DOCKER ENDPOINT                  KUBERNETES ENDPOINT   ORCHESTRATORdefault *           Current DOCKER_HOST based configuration   npipe:////./pipe/docker_engine                         swarm

Go back into your wsl/ubuntu setup and type export DOCKER_HOST=unix:///var/run/docker.sock