Docker 无法在 Windows 上启动。

451

Windows 上执行 docker version 命令将返回以下结果:

C:\Projects> docker version
Client:
 Version:      1.13.0-dev
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   d8d3314
 Built:        Tue Nov  1 03:05:34 2016
 OS/Arch:      windows/amd64
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.25/version: open //./pipe/docker_engine: The system cannot find the file
specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.

运行诊断程序会产生以下结果:

C:\Projects> wget https://github.com/Microsoft/Virtualization- 
Documentation/raw/master/windows-server-container-tools/Debug- 
ContainerHost/Debug-ContainerHost.ps1 -UseBasicParsin | iex

Checking for common problems
Describing Windows Version and Prerequisites
 [+] Is Windows 10 Anniversary Update or Windows Server 2016 608ms
 [+] Has KB3192366, KB3194496, or later installed if running Windows build 14393 141ms
 [+] Is not a build with blocking issues 29ms
Describing Docker is installed
 [-] A Docker service is installed - 'Docker' or 'com.Docker.Service'  134ms
   Expected: value to not be empty
   27:         $services | Should Not BeNullOrEmpty
   at <ScriptBlock>, <No file>: line 27
 [+] Service is running 127ms
 [+] Docker.exe is in path 2.14s
Describing User has permissions to use Docker daemon
 [+] docker.exe should not return access denied 42ms
Describing Windows container settings are correct
 [-] Do not have DisableVSmbOplock set to 1 53ms
   Expected: {0}
   But was:  {1}
   66:              $regvalue.VSmbDisableOplocks | Should Be 0
   at <ScriptBlock>, <No file>: line 66
 [+] Do not have zz values set 42ms
Describing The right container base images are installed
error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.25/images/json: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuration on Windows, the docker client must be run elevated to connect. This error may also indicate that the docker daemon is not running.
 [-] At least one of 'microsoft/windowsservercore' or 'microsoft/nanoserver' should be installed 129ms
   ValidationMetadataException: The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
   ParameterBindingValidationException: Cannot validate argument on parameter 'Property'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.
   at <ScriptBlock>, <No file>: line 90
Describing Container network is created
 [-] Error occurred in Describe block 1.08s
   RuntimeException: Cannot index into a null array.
   at <ScriptBlock>, <No file>: line 119
Showing output from: docker info

Showing output from: docker version
Client:
 Version:      1.13.0-dev
 API version:  1.25
 Go version:   go1.7.3
 Git commit:   d8d3314
 Built:        Tue Nov  1 03:05:34 2016
 OS/Arch:      windows/amd64

Showing output from: docker network ls

Warnings & errors from the last 24 hours
Logs saved to C:\Projects\logs_20161107-084122.csv
C:\Projects>

32
我得出结论,Windows 上的技术还不够成熟。在技术成熟之前,请使用 Linux Docker。 - Jim
使用此命令 docker-machine create box。请参考 https://github.com/docker/toolbox/issues/636。 - Mr Nobody
请确保您已经按照文档 https://docs.docker.com/machine/get-started/ 中的设置步骤进行了操作。 - fanny
有时在初始安装时会出现这种情况,但只需完成勾选接受服务级别协议的程序即可。通常,在电脑上搜索Docker桌面并单击其图标即可。 - Gilbert
1
同样适用于2021年:在问题中提到的诊断脚本的更新URL是 wget https://github.com/Microsoft/Virtualization-Documentation/raw/main/windows-server-container-tools/Debug-ContainerHost/Debug-ContainerHost.ps1 -UseBasicParsin | iex - Ben Seymour
显示剩余3条评论
61个回答

4

在 PowerShell 或 Git Bash 中打开 C 盘,并运行以下命令

.\Program Files\Docker\Docker\DockerCli.exe -SwitchDaemon

3
对于我来说,错误是通过停止在Hyper-V中运行的虚拟Ubuntu实例来解决的:
“在Windows上的默认守护程序配置中,必须以提升权限运行docker客户端才能连接。此错误还可能表示docker守护程序没有运行。”
一旦Ubuntu实例停止,并重新启动Docker Desktop,我的常规docker命令就可以正常运行了。
PS:我之所以想尝试这个方法,是因为Docker Desktop编译并提供了一个错误日志,作为用户反馈发送给Docker Hub… 日志似乎表明我的机器缺少RAM,而Docker因这个非常简单的原因而失败了。杀死Ubuntu实例解决了这个问题。

3

最近我也遇到了同样的问题。问题出在安全软件(趋势科技)阻止了docker创建Hyperv网络接口。你还应该检查防火墙、杀毒软件是否阻止了安装或配置。


3

3
安装 Docker Desktop 到你的 Windows 电脑后,你可能会找到这个位置。它的实际作用是什么?它通过命令行界面启动 Docker Daemon。
"C:\Program Files\Docker\Docker\DockerCli.exe" -SwitchDaemon

请提供更多细节说明您的答案,否则可能会被标记为低质量。 - Ethan Vu
安装Docker桌面版到你的电脑(Windows系统),你可以找到这个位置。它实际上是通过CLI启动Docker守护进程。 - Dinuwan Kalubowila
我根据你的评论编辑了你的答案以添加细节。你也可以自己编辑答案。还有一篇关于撰写获得赞同的答案的文章,很不错。 - Ethan Vu

3

我的一个朋友遇到了类似的问题,我们尝试了以下方法解决了问题。

尽管Hyper-V在“打开或关闭Windows功能”中被列为已激活状态,但实际上它并没有激活。当在PowerShell下运行systeminfo时,会发现要求被列为已满足(如果实际上Hyper-V正在运行,您将不会看到这个输出)。步骤如下:

  1. 打开“打开或关闭Windows功能”
  2. 如果您不确定如何操作,请参考此链接
  3. 关闭Hyper-V(取消选中复选框,并确保所有子组件都标记为已关闭)
  4. 点击“确定” - 您的计算机将重新启动。
  5. 当您的计算机再次启动时,打开“打开或关闭Windows功能”,并重新启用Hyper-V。您的机器将再次重新启动。

现在,您可以通过运行Docker hello-world图像进行测试。


3

您也可以使用自诊工具

Docker Desktop包含一个自诊工具,帮助您识别一些常见问题。在运行自诊工具之前,请先找到com.docker.diagnose.exe文件。通常安装在C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe。

在Powershell中运行自诊工具的命令:

& "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check

该工具运行一系列检查,并在每个检查旁边显示“PASS”或“FAIL”。如果有任何失败,则在最后突出显示最相关的失败原因。
然后运行此命令。
& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon

3

针对win10-home,以下方法适用:https://github.com/docker/for-win/issues/11967

  1. 关闭docker服务
  2. 在命令终端窗口中执行以下命令
    RMDIR /S %USERPROFILE%\AppData\Roaming\Docker
  3. 启动docker服务
  4. 点击“Docker桌面”

现在,“Docker Desktop”将会正在运行... 完成... :)


我也在使用Win 10家庭版(已安装WSL 2)。我得到: - Andrew

3

在Windows 10机器上安装: 在安装之前,在搜索中搜索Windows功能,并勾选Windows Hypervisor平台和子系统Linux windows features

安装WSL 1或2是必须的,因此在docker提示你安装它时,请安装它。

https://learn.microsoft.com/en-us/windows/wsl/install-win10

您需要从Windows商店安装Ubuntu(版本16、18或20):

Ubuntu版本20

安装后,您可以在Linux终端中运行命令,例如docker -versiondocker run hello-world

这个视频会有所帮助: https://www.youtube.com/watch?v=5RQbdMn04Oc&t=471s


3

我正在使用Windows 7,配合Docker Toolbox使用。如果需要修复问题,请打开Docker Quickstart Terminal

$ docker version 客户端: 版本:17.05.0-ce API版本:1.29 Go版本:go1.7.5 Git提交:89658be 构建时间:2017年5月5日 15:36:11 操作系统/架构:windows/amd64

服务器: 版本:17.05.0-ce API版本:1.29(最低版本为1.12) Go版本:go1.7.5 Git提交:89658be 构建时间:2017年5月4日21:43:09 操作系统/架构:linux/amd64 实验性功能:false


1
在我的情况下,我不得不打开我安装在电脑上的“Docker Desktop”应用程序来解决这个错误。 - Bhanu Chander

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接