[英]docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? Linux Bash Shell on windows 10
I am new to Docker.我是 Docker 的新手。 I'm trying to work with it on windows.我正在尝试在 Windows 上使用它。 I have Windows 10 Family so I installed Linux Bash Shell.我有 Windows 10 系列,所以我安装了 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?
我得到: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
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
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 .正如官方文档中所述,您似乎无法在 Windows 10 family
使用 docker,因为 docker Desktop 需要特定的 Windows 版本。
System Requirements系统要求
Windows 10 64-bit: Pro, Enterprise, or Education (Build 15063 or later). Windows 10 64 位:专业版、企业版或教育版(内部版本 15063 或更高版本)。
What you can try is to run linux-based virtual machine on you Windows host, and run docker inside of it.您可以尝试在 Windows 主机上运行基于 linux 的虚拟机,并在其中运行 docker。 But even if you succeeded, you will lose all advantages of the docker in resources consumption.但即使你成功了,你也会失去 docker 在资源消耗方面的所有优势。
For anyone using WSL2 and seeing an identical error message, look at https://github.com/MicrosoftDocs/WSL/issues/457#issuecomment-511495846对于使用 WSL2 并看到相同错误消息的任何人,请查看https://github.com/MicrosoftDocs/WSL/issues/457#issuecomment-511495846
Powershell电源外壳
wsl -l -v
NAME STATE VERSION
* Ubuntu-20.04 Running 2
Ubuntu 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.
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.这里的问题是,从错误消息中,它指出您正在使用 WSL(Linux 版本 1 的 Windows 子系统),该版本没有 Docker 支持,因为它不是一个完整的 Linux 内核,而是一个然后将 Linux 用户空间转换为 Windows 内核命令。
Running the wsl --list -v
command will show you the version you are using:运行wsl --list -v
命令将显示您正在使用的版本:
You can install WSL version 2, which has a Microsoft provided full Linux Kernel running using Hyper-V infrastructure (but not full Hyper-V).您可以安装 WSL 版本 2,它具有 Microsoft 提供的使用 Hyper-V 基础架构(但不是完整的 Hyper-V)运行的完整 Linux 内核。 This way it runs on Windows Home, Education, and Professional.这样它就可以在 Windows Home、Education 和 Professional 上运行。 And here you can run a Linux Instance and the install Docker.在这里您可以运行 Linux 实例并安装 Docker。
Windows Subsystem for Linux Installation Guide 适用于 Linux 的 Windows 子系统安装指南
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.