问题描述
我在运行时遇到这个错误
I am getting this error while running
>service docker start
docker: unrecognized service
>service docker.io start
docker.io: unrecognized service
我正在努力使用 docker 来运行它.我收到 无法连接到 unix:///var/run/docker.sock 上的 Docker 守护进程.docker 守护进程是否正在运行?
错误.此后我尝试了几件事,但没有奏效.
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.
我在 Windows 系统中使用 ubuntu 18.04 应用程序.我该怎么办?
I'm using ubuntu 18.04 app in windows system. what should I do?
推荐答案
好像 WSL 无法连接到通过 Docker for Windows 运行的 docker 守护进程,可能是因为它没有暴露或没有运行.
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
如果您使用的是 WSL 1,您可以在 Docker for Windows 中通过此选项公开 docker 守护进程:我推荐 这个 文章以获得详细指南.
In case you are using WSL 1, you can expose the docker daemon through this option in Docker for Windows:I recommend this article for a detailed guide.
我强烈建议在 WSL 2 中运行 docker,因为它提供更快的启动时间,并允许 docker 动态使用 CPU/RAM,而不必预先分配它.
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
如果您使用的是 WSL 2,则必须通过 Docker for Windows 为 docker 启用 WSL 2 后端.docker 团队在此处有一份详尽的指南.
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.
这篇关于码头工人:无法识别的服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!