Pau
Pau

Reputation: 16116

Docker-machine create: Error with pre-create check: "Hyper-v commands have to be run as an Administrator"

I try to create a docker-machine with docker for Windows 10 using next command:

docker-machine create --driver hyperv default

But I get the next error

Error with pre-create check: "Hyper-v commands have to be run as an Administrator"

Anyone knows how to fix this issue? Thanks

Upvotes: 5

Views: 6191

Answers (3)

Olli
Olli

Reputation: 1651

Simply start cmd (terminal) as admin.

Otherwise, if this does not work: there is a known issue #2989 in docker machine: the creation of a Docker machine fails with the error message "Hyper-v commands have to be run as an Administrator", even if your user is member of the Hyper-V Administrator group and the Hyper-V Administrators have full access to the folder containing the VM:

λ Get-Acl E:\docker\ | Format-List ... Access : BUILTIN\Hyper-V Administrators Allow FullControl

jtnord has found a workaround by creating a VM with fixed-size disk. He has tested this for users that are group members of Hyper-V Administrators and he has given FullControl for the base Folder for Hyper-V Administrators, as I understand it.

Upvotes: 8

Whoiskp
Whoiskp

Reputation: 454

Just Add your current user to "Local Group": 'Hyper-V Administrators'.

Check your <current username> by:

> whoami

Start cmd.exe by Administrator:

  1. Check localgroup by: > net localgroup
  2. Add to Hyper-V Admininstrators: > net localgroup "Hyper-V Administrators" <current username> /add
  3. Sign out or Reboot

Upvotes: 5

Scott Lindner
Scott Lindner

Reputation: 584

You can change the properties on the docker-machine executable to Run As Administrator. The file is located (at least on my box) in C:\Program Files\Docker\Docker\resources\bin\docker-machine.exe Find this file, right click and select Compatibility and check the box "Run this program as an administrator".

Upvotes: 1

Related Questions