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

Created on 2 Apr 2018  路  8Comments  路  Source: docker/machine

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:WINDOWSsystem32> 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"

Most helpful comment

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

~~log
Running pre-create checks...
(myvm1) Image cache directory does not exist, creating it at C:UsersTrey Brister.dockermachinecache...
(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:UsersTrey Brister.dockermachinecacheboot2docker.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:UsersTrey Brister.dockermachinecacheboot2docker.iso to C:UsersTrey Brister.dockermachinemachinesmyvm1boot2docker.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 FilesDockerDockerResourcesbindocker-machine.exe env myvm1
~
~

All 8 comments

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 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>

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

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

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

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

~~log
Running pre-create checks...
(myvm1) Image cache directory does not exist, creating it at C:UsersTrey Brister.dockermachinecache...
(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:UsersTrey Brister.dockermachinecacheboot2docker.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:UsersTrey Brister.dockermachinecacheboot2docker.iso to C:UsersTrey Brister.dockermachinemachinesmyvm1boot2docker.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 FilesDockerDockerResourcesbindocker-machine.exe env myvm1
~
~

Im getting this error even after downloading the file specified.

PS C:ReposDockerGetStarted> 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

Im getting this error even after downloading the file specified.

PS C:ReposDockerGetStarted> 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 ...
  • <ul> <li>CategoryInfo : NotSpecified: (Error with pre-...chmd5-788ada77998584e4a00d01760f302bcf" not found":String) [], RemoteException</li> <li>FullyQualifiedErrorId : NativeCommandError<br />

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

Was this page helpful?
0 / 5 - 0 ratings