docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Linux Bash Shell on windows 10

Viewed 15980

I am new to Docker. I'm trying to work with it on windows. I have Windows 10 Family so I installed Linux Bash Shell. When I run this command:

$ docker run hello-world

I get : docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. And when I run

$ systemctl status docker

I get

System has not been booted with systemd as init system (PID 1). Can't operate
3 Answers

For anyone using WSL2 and seeing an identical error message, look at https://github.com/MicrosoftDocs/WSL/issues/457#issuecomment-511495846

Powershell

wsl -l -v

  NAME            STATE           VERSION
* Ubuntu-20.04    Running         2

Ubuntu

$ docker run hello-world

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

$ systemctl status docker

System has not been booted with systemd as init system (PID 1). Can't operate.

$ sudo /etc/init.d/docker start

 * Starting Docker: docker                                                                                                                         [ OK ]

 $ sudo docker run hello-world

 Unable to find image 'hello-world:latest' locally
 latest: Pulling from library/hello-world
 b8dfde127a29: Pull complete
 Digest: sha256:308866a43596e83578c7dfa15e27a73011bdd402185a84c5cd7f32a88b501a24
 Status: Downloaded newer image for hello-world:latest

 Hello from Docker!
 This message shows that your installation appears to be working correctly.

It seems like you wont be able to use docker in Windows 10 family, since docker Desktop requires specific Windows version, as said in official documentation.

System Requirements

Windows 10 64-bit: Pro, Enterprise, or Education (Build 15063 or later).

What you can try is to run linux-based virtual machine on you Windows host, and run docker inside of it. But even if you succeeded, you will lose all advantages of the docker in resources consumption.

The issue here is that from the error message, it states that you are using WSL (Windows Sub-system for Linux Version 1), this version did not have Docker support as it is not a full Linux kernel, but an translation layer between a Linux user-space and then translated to Windows Kernel commands.

Running the wsl --list -v command will show you the version you are using:

enter image description here

You can install WSL version 2, which has a Microsoft provided full Linux Kernel running using Hyper-V infrastructure (but not full Hyper-V). This way it runs on Windows Home, Education, and Professional. And here you can run a Linux Instance and the install Docker.

Windows Subsystem for Linux Installation Guide

Related