vibhu sharma
vibhu sharma

Reputation: 525

docker: unrecognized service

I am getting this error while running

>service docker start                                                       
docker: unrecognized service
>service docker.io start                                                    
docker.io: unrecognized service

I am struggling with docker in order to run it. I got Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? error. thereafter I tried several things but it did not work.

>docker pull pstothard/cgview                                               
Using default tag: latest                                                                                      
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

 >sudo docker run hello-world                                                
 docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.

>systemctl start docker.service                                             
System has not been booted with systemd as init system (PID 1). Can't operate.

>docker images                                                             
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: 
Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/images/json: dial unix /var/run/docker.sock: connect: permission denied 

>snap stop docker                                                           
Interacting with snapd is not yet supported on Windows Subsystem for Linux.                                      
This command has been left available for documentation purposes only.

I'm using ubuntu 18.04 app in windows system. what should I do?

Upvotes: 26

Views: 108523

Answers (5)

Dan
Dan

Reputation: 1

For anyone using WSL2 and still having this issue. I recently encountered this and had to specifically select my distro under Resources->WSL integration shown below.

Docker WSL Integration tab

Upvotes: 0

CodeManX
CodeManX

Reputation: 11915

Despite Ubuntu WSL configured for WSL2, it didn't work for me. The problem turned out to be that Ubuntu wasn't the default distro as indicated by the asterisk when you run wsl -l -v on the Windows host:

  NAME                   STATE           VERSION
* docker-desktop-data    Running         2
  docker-desktop         Running         2
  Ubuntu                 Running         2

You don't necessarily have to change the default distro. You can also enable the WSL integration for additional distros. Open Docker Desktop, click the gear icon to open the Settings panel, and under Resources select WSL integration. Enable the toggle for the WSL distro, e.g. Ubuntu, below the text Enable integration with additional distros:

A screenshot of the Docker Desktop Settings panel with the Resources - WSL integration section selected, showing the text 'Enable integration with additional distros' and an activated toggle for Ubuntu

Click Apply & Restart.

docker run hello-world should then succeed in the WSL Ubuntu (but service docker status still reports docker: unrecognized service). If it's still failing, try restarting Docker Desktop manually. It might also help to run wsl --terminate Ubuntu and wait for the following dialog to come up:

Docker Desktop asking whether to restart the WSL integration

Click Restart the WSL integration. As a last resort, maybe reboot your host machine.

Upvotes: 3

Oyefule Oluwatayo
Oyefule Oluwatayo

Reputation: 1

I had a similar issue, what I simply did was to set my default Linux distro. Try running wsl --setdefault <distroName>. In my case wsl --setdefault ubuntu. You should be able to run commands after this.

Upvotes: 0

McColtney
McColtney

Reputation: 51

Try starting the docker deamon manually (sudo dockerd) if the sudo docker run hello-world returns Is the docker daemon running?.

Upvotes: 5

tenstan
tenstan

Reputation: 1319

Seems like WSL cannot connect to the docker daemon running through Docker for Windows, probably because it is not exposed or is not running.

WSL1

In case you are using WSL 1, you can expose the docker daemon through this option in Docker for Windows: enter image description here I recommend this article for a detailed guide.

I would highly recommend running docker within WSL 2 instead, since it provides faster boot times and allows docker to use CPU/RAM dynamically instead of you having to preallocate it.

WSL2

In case you are using WSL 2, you will have to enable the WSL 2 back-end for docker through Docker for Windows. The docker team has an extensive guide on this here.

Upvotes: 9

Related Questions