码头工人:无法识别的服务

时间:2020-07-21 10:49:39

标签: docker shell windows-subsystem-for-linux

我在运行时遇到此错误

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

我正在努力与docker合作以运行它。我遇到了Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?错误。此后,我尝试了几件事,但没有成功。

>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.

我在Windows系统中使用ubuntu 18.04应用程序。我该怎么办?

1 个答案:

答案 0 :(得分:3)

好像WSL无法连接到通过Docker for Windows运行的docker守护进程,可能是因为它未公开或未运行。

WSL1

如果使用的是WSL 1,则可以通过Windows版Docker中的此选项公开docker守护进程: enter image description here 我推荐this文章以获取详细指南。

我强烈建议改为在WSL 2中运行docker,因为它提供了更快的启动时间,并允许docker动态使用CPU / RAM,而无需您预先分配它。

WSL2

如果您使用的是WSL 2,则必须通过Windows的Docker启用Docker的WSL 2后端。码头工人团队对此here有广泛的指导。