Docker Machine error: Hyper-V PowerShell Module is not available

Docker Machine error: Hyper-V PowerShell Module is not available

我检查了我的 Hyper-V 设置并启用了 PowerShell 模块。我还发现了这个记录在案的问题:https://github.com/docker/machine/issues/4342 但这不是同一个问题,因为我没有安装 VMware PowerCLI。这个问题通过推送到 repo 来解决,并且应该在 0.14.0-rc1 中修复,构建 e918c74 所以我还是尝试了它。更换我的 docker-machine.exe 后,我仍然收到错误消息,即使我为 Windows.

重新安装 Docker 也仍然收到错误消息

关于更多背景信息,此错误在重新安装后开始发生,因为我的 Docker 安装有一个错误:https://github.com/docker/for-win/issues/1691,但是,我在重新安装后不再遇到该问题。

致那些在 Windows、Follow the instruction here

遇到这个问题的人

在 win10 上使用 docker-machine 创建 Hyper-v VM 时,返回错误"Error with pre-create check: "Hyper-V PowerShell 模块不可用”。

解决方法很简单。原因是 docker-machine 程序的版本。将其替换为 v0.13.0。详细操作如下:

  1. 下载0.13.0版本的docker-machine命令。点击下载:32位系统或64位系统

  2. 下载完成后,重命名并替换“C:\ProgramFiles\Docker\Docker\resources\bin”目录下的“docker-machine.exe”文件。最好备份原文件

(1), V0.15官方修复了这个问题: 修复问题 #4424 - 创建前检查:“Hyper-V PowerShell 模块不可用” 官方介绍: https://github.com/docker/machine/pull/4426 V0.15下载地址 https://github.com/docker/machine/releases

(2), 我测试了这个,它工作正常。 无需重启docker 将"docker-machine.exe"替换为0.15

版本后立即生效

(3), 备份原来的是个好习惯

这是解决方案

https://github.com/docker/machine/releases/download/v0.15.0/docker-machine-Windows-x86_64.exe

将下载的文件保存到包含 docker-machine.exe.

的现有目录

对于我的系统,这是 docker-machine.exe 的位置 /c/Program Files/Docker/Docker/Resources/bin/docker-machine.exe

备份旧文件并用新文件替换它。

cp docker-machine.exe docker-machine.014.exe

将下载的文件名重命名为docker-machine.exe

mv docker-machine-Windows-x86_64.exe docker-machine.exe

构建说明

  1. 在名为 myswitch
  2. 的 Hyper-V 管理器中创建虚拟交换机
  3. 请求 Docker 创建一个名为 myvm1
  4. 的 VM

docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1

结果

docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1

Running pre-create checks... (myvm1) Image cache directory does not exist, creating it at C:\Users\Trey Brister\.docker\machine\cache... (myvm1) No default Boot2Docker ISO found locally, downloading the latest release... (myvm1) Latest release for github.com/boot2docker/boot2docker is v18.05.0-ce (myvm1) Downloading C:\Users\Trey Brister\.docker\machine\cache\boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v18.05.0-ce/boot2docker.iso... (myvm1) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100% Creating machine... (myvm1) Copying C:\Users\Trey Brister\.docker\machine\cache\boot2docker.iso to C:\Users\Trey Brister\.docker\machine\machines\myvm1\boot2docker.iso... (myvm1) Creating SSH key... (myvm1) Creating VM... (myvm1) Using switch "myswitch" (myvm1) Creating VHD (myvm1) Starting VM... (myvm1) Waiting for host to start... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with boot2docker... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe env myvm1