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个回答

6

我曾经遇到过同样的问题,这可能是管理员的问题,因此按照以下步骤在Windows10上设置docker:

  1. 登录docker后从docker hub下载docker桌面版。会下载一个名为Docker Desktop Installer.exe的文件。
  2. 使用以管理员身份运行来安装Docker Desktop Installer.exe->在安装期间选择windows容器,否则只会安装linux容器。安装完成后会要求注销,注销并重新登录即可在菜单中看到docker桌面版。
  3. 安装完毕后,进入->计算机管理 ->本地用户和组 ->组->docker-user->将用户添加到成员中 输入图像说明
  4. 使用以管理员身份运行来运行docker桌面版 输入图像说明
  5. 在通知选项卡中检查docker鲸鱼图标 输入图像说明
  6. 运行命令 >docker version 输入图像说明 成功使用docker,没有任何问题。

请记得重新启动您的电脑以使更改生效。这可以作为第四步。 - Seun Matt

6

请尝试以下两种选项来解决问题:

选项 A

Start-Service "Hyper-V Virtual Machine Management"
Start-Service "Hyper-V Host Compute Service"

选项 B

  1. 打开“Windows 安全”

  2. 打开“应用和浏览器控制”

  3. 在底部点击“利用保护设置”

  4. 切换到“程序设置”选项卡

  5. 在列表中找到“C:\WINDOWS\System32\vmcompute.exe”,并展开它

  6. 点击“编辑”

  7. 滚动到“代码流程保护 (CFG)”,取消勾选“覆盖系统设置”

  8. 从 Powershell 启动 vmcompute:"net start vmcompute"

  9. 然后重启您的系统


这不容易受到攻击吗? - WaterRocket8236
除了我尝试过的其他推荐解决方案都没有起作用之外,选项B是我最后尝试的事情。重启后,它没有起作用,但然后我登录管理员帐户并尝试在那里运行docker。Docker要求更新,更新后Docker客户端能够启动。因此,我重新登录到我的帐户,Docker客户端启动并正常工作。 - niio

6
原因:可能是因为我们使用命令关闭了vmmem
wsl --shutdown

解决方案:右键点击重新启动 Docker 即可解决该问题。

输入图片说明


有没有更好的方法来关闭它? - Hassan Faghihi
@deadManN 以上命令不工作吗? - mabdullahse
不,它运行得很好,甚至比命令更好,因为建议的命令需要多次击打...我正在寻找一种更好的方法来关闭WSL而不会中断它,并引起许多问题...既然您已经知道了一种新的重启方式,我想您可能也知道一种更好的关闭方式,而不是使用“wsl --shutdown”。 - Hassan Faghihi

5
如果你已经在启用了 Hyper-V 的 Windows 10 Pro 上安装了 Docker,但仍无法在 Windows 10 上运行 Docker,则根据错误提示,你的 Docker 守护程序未启动。
以下步骤可以帮助我成功启动 Docker:
  1. Use command on cmd(Admin mode)

    docker-machine restart default
    
  2. Then you'll get a message something like:

    open C:\User\\{User_name}\\.docker\machine\machines\default\config.json:
    The system cannot find the file specified.

  3. Go to the docker icon which will be on your windows tray (bottom right corner of the desktop)

  4. Right click on the docker icon > Settings > Reset > Restart Docker

    It will take few moments

  5. Then you'll see the following message:

    Docker is running with the green indicator

注意: 如果您的系统上已经有正在运行的Docker容器,则不要按照以下步骤操作。否则您可能会丢失现有的容器。

进入图片描述


3
Docker机器“default”不存在。使用“docker-machine ls”列出机器。使用“docker-machine create”添加一个新的机器。 - Chloe

5

当我在Windows 10上开始使用Docker时,遇到了同样的问题。我能够成功运行docker --version,但是在尝试运行docker pull docker/whalesay时失败了。
我尝试了这里提供的许多解决方案,但当我按照以下步骤操作后,我的问题得到了解决:
1. 在Windows中搜索docker并以管理员身份运行docker桌面版。
2. 检查左下角的docker标志,如果docker正在运行,则应该是绿色的。
3. 如果未运行,请首先安装"wsl_update"。
4. 打开docker桌面版并使用您的docker凭据登录,当您登录时,您可以看到服务器正在重新启动,并且左下角的标志变为绿色。
5. 要检查docker是否正在运行,请以管理员身份打开PowerShell并运行docker run hello-world


第三步在我的情况下解决了问题。 - atakli

4

如果您使用的是Windows操作系统,请尝试以下方法:

 docker-machine env --shell cmd default 
 @FOR /f "tokens=*" %i IN ('docker-machine env --shell cmd default') DO @%i

进行测试尝试

docker run hello-world

4
对我而言,问题在于虚拟化未被启用。
在Windows 10上:转到任务管理器 -> 性能 -> CPU,您应该看到一个名为“虚拟化:已启用”的部分。
如果您没有看到此选项,则表示虚拟化未被启用。
另一个有趣的事情需要注意的是,您必须启用Hyper V。但是,由于我正在使用Parallels Desktop,我必须启用“嵌套虚拟化”才能真正启用Hyper V。因此,如果您的Windows是VM,请查看Parallels(或您正在使用的任何其他软件)的设置,确保已启用嵌套虚拟化。

4
我在Windows 10中安装后遇到了同样的错误。我尝试了重新启动,但没有奏效,所以我做了以下操作(如果您已经在docker上工作了一段时间,不建议这样做,因为此方法适用于新安装):
1)在系统托盘中找到鲸鱼图标,右键单击
2)进入设置>重置
3)恢复出厂设置
然后我就能够在Windows 10上按照网站上的教程启动docker了,现在它工作得非常好。

系统托盘中没有鲸鱼。 - Chloe
我的计算机上有一个默认的虚拟机正在运行,它正在运行Docker Worker。我重置了该虚拟机,然后解决了Windows中的Docker错误。 - Derrick

4

我的解决方案很简单。我注意到 Docker 运行的是 Linux 容器而不是 Windows 容器。我所做的就是通过在系统托盘中右键单击 Docker 图标并选择切换到 Windows 容器来切换到 Windows 容器。


4

按照Github问题中的指示,删除%appdata%\Docker文件夹。

为了快速访问,请按Ctrl+R,粘贴"%appdata%\Docker",然后按下Enter,它应该打开位于AppData\Roaming\Docker的文件夹(例如C:\Users\YourUsername\AppData\Roaming\Docker)。


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