machine icon indicating copy to clipboard operation
machine copied to clipboard

Pre-create checks fail when creating a Hyper-V machine. PowerShell module is not available.

Open corthon opened this issue 8 years ago • 8 comments

I have verified multiple times that the PowerShell management module is installed. Currently working with: Version 18.03.0-ce-win59 (16762) Channel: stable d70d80d

I may uninstall and try a previous version.

PS C:\WINDOWS\system32> docker-machine create -d hyperv --hyperv-memory 4096 default Running pre-create checks... Error with pre-create check: "Hyper-V PowerShell Module is not available"

corthon avatar Apr 02 '18 03:04 corthon

I tried a workaround provided by @ramit-rulz: downgrade docker-machine and it did work for me, but only to uncover another issue down the road... "This machine has been allocated an IP address, but Docker Machine could not reach it successfully"

LeonardoMontano avatar Apr 02 '18 11:04 LeonardoMontano

@LeonardoMontano This error is because by default Hyper-V allocates only IPv6 IP. For IPv4, you need to create External Network Switch

Try creating new docker machine using this command - docker-machine create -d hyperv --hyperv-virtual-switch "<NameOfVirtualSwitch>" <nameOfNode>

samirsyed avatar Apr 02 '18 14:04 samirsyed

@LeonardoMontano and @samirsyed, thank you very much! It worked. Couldn't figure out how to find the older version on my own.

corthon avatar Apr 02 '18 15:04 corthon

Reopening because the underlying issue still exists. Was able to work-around with above suggestion.

corthon avatar Apr 02 '18 15:04 corthon

Thank you @samirsyed Yes, I create an external switch and I still get the error. More details on issue #4440

LeonardoMontano avatar Apr 03 '18 13:04 LeonardoMontano

Here is the solution

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

Save the downloaded file to your existing directory containing docker-machine.exe.

For my system this is the location for docker-machine.exe /c/Program Files/Docker/Docker/Resources/bin/docker-machine.exe

Backup the old file and replace it file with the new one.

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

Rename the downloaded filename to docker-machine.exe

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

Build Instructions

  1. Create virtual switch in Hyper-V manager named myswitch
  2. Request Docker to create a VM named myvm1

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

Results

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

webstandardcss avatar Jul 17 '18 05:07 webstandardcss

Im getting this error even after downloading the file specified.

PS C:\Repos\DockerGetStarted> docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1 Running pre-create checks... docker-machine : Error with pre-create check: "vswitch "myswitch" not found" At line:1 char:1

  • docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" my ...
  •   + CategoryInfo          : NotSpecified: (Error with pre-...ch\" not found":String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    

hethiorsteddk avatar Aug 06 '19 06:08 hethiorsteddk

Im getting this error even after downloading the file specified.

PS C:\Repos\DockerGetStarted> docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" myvm1 Running pre-create checks... docker-machine : Error with pre-create check: "vswitch "myswitch" not found" At line:1 char:1

  • docker-machine create -d hyperv --hyperv-virtual-switch "myswitch" my ...
  •   + CategoryInfo          : NotSpecified: (Error with pre-...ch\" not found":String) [], RemoteException
      + FullyQualifiedErrorId : NativeCommandError
    

You need to create vswitch in Hyper-V Manager (you can find it by search in you OS). As example, watch this video https://www.youtube.com/watch?v=cGlrw4P-VUQ

AlexandrRomanychev avatar May 25 '20 08:05 AlexandrRomanychev