for-win icon indicating copy to clipboard operation
for-win copied to clipboard

Docker fails to start - MobyLinuxVM.vhdx already exists, unable to create MobyLinuxVM

Open qwebek opened this issue 10 years ago • 32 comments

Expected behavior

Docker is started

Actual behavior

Docker fails to start

VHD C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx already exists HyperV ][Info ] Creating VM MobyLinuxVM... [NamedPipeServer][Error ] Unable to execute Start: Unable to create:

Information

  • E3B820D1-EFA6-4097-BA0E-BA68982EE30D/2016-08-31_12-00-32
  • a reproducible case if this is a bug, Dockerfiles FTW
  • page URL if this is a docs issue or the name of a man page
  • Windows 10 Enterprise 1511

Steps to reproduce the behavior

  1. Install Docker stable or beta
  2. Check checkbox Launch docker on last step of install

[14:28:21.384][HyperV ][Info ] VHD C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx already exists [14:28:21.476][HyperV ][Info ] Creating VM MobyLinuxVM... [14:28:23.188][NamedPipeServer][Error ] Unable to execute Start: Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Hyper-V encountered an error trying to access an object on computer 'XXX' because the object was not found. The object might have been deleted, or you might not have permission to perform the task. Verify that the Virtual Machine Management service on the computer is running. If the service is running, try to perform the task again by using Run as Administrator. at New-MobyLinuxVM, : line 202 at , : line 321 at Docker.Backend.HyperV.RunScript(String action, Dictionary`2 parameters) at Docker.Backend.LinuxContainersEngine.Start(Settings settings) at Docker.Core.Pipe.NamedPipeServer.<>c__DisplayClass7_0.b__0(Object[] parameters) at Docker.Core.Pipe.NamedPipeServer.RunAction(String action, Object[] parameters) [14:28:23.497][NamedPipeClient][Error ] Unable to send Start: Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Hyper-V encountered an error trying to access an object on computer 'XXX' because the object was not found. The object might have been deleted, or you might not have permission to perform the task. Verify that the Virtual Machine Management service on the computer is running. If the service is running, try to perform the task again by using Run as Administrator. at New-MobyLinuxVM, : line 202 at , : line 321 [14:28:23.498][Notifications ][Error ] Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Hyper-V encountered an error trying to access an object on computer 'XXX' because the object was not found. The object might have been deleted, or you might not have permission to perform the task. Verify that the Virtual Machine Management service on the computer is running. If the service is running, try to perform the task again by using Run as Administrator. at New-MobyLinuxVM, : line 202 at , : line 321 [14:28:23.550][NamedPipeClient][Info ] Sending GetDebugInfo()... [14:28:23.551][NamedPipeServer][Info ] GetDebugInfo() [14:28:51.999][NamedPipeServer][Info ] GetDebugInfo done.

qwebek avatar Aug 31 '16 09:08 qwebek

Several weeks fighting this error :) but no luck

I have tried running docker as administrator, made reset to defaults, check for updates, - error is the same :( Ther is possibility to create internal and external virtual switches in Hyper-v

Found almost nothing regarding this particular error, have another PC with the same configuratoin and there was no docker install issues there... i have compared windows versions, Hyper-v setting through hyper-v manager, everything is the same or at least basic things

Can anyone help?

qwebek avatar Aug 31 '16 09:08 qwebek

@qwebek Thanks for reporting...this is a weird one, I haven't seen before. I assume you have tried un-installing and re-installing again...

Can you also try the following after exiting the docker for windows application via the whale systray icon from an elevated powershell:

Stop-Service com.docker.service
& 'C:\Program Files\Docker\Docker\resources\MobyLinux.ps1' -destroy

and then start the App again via the Desktop icon. You should get prompted that the service is not running, select Start and then also accept the UAC. If this still fails, it would be great if you could upload another diagnostics report and let us know the ID.

rn avatar Aug 31 '16 18:08 rn

Thanks for responding! im not alone)

PS C:\Users\XXX> Stop-Service com.docker.service WARNING: Waiting for service 'Docker for Windows Service (com.docker.service)' to stop... PS C:\Users\XXX> & 'C:\Program Files\Docker\Docker\resources\MobyLinux.ps1' -destroy VM MobyLinuxVM does not exist Destroying Switch DockerNAT... Removing VM MobyLinuxVM... Delete VHD C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx PS C:\Users\XXX>

Result looks like the same E3B820D1-EFA6-4097-BA0E-BA68982EE30D/2016-09-01_00-12-17

[00:12:06.355][HyperV ][Info ] VHD C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx already exists [00:12:06.401][HyperV ][Info ] Creating VM MobyLinuxVM... [00:12:07.774][NamedPipeServer][Error ] Unable to execute Start: Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Hyper-V encountered an error trying to access an object on computer 'XXX' because the object was not found. The object might have been deleted, or you might not have permission to perform the task. Verify that the Virtual Machine Management service on the computer is running. If the service is running, try to perform the task again by using Run as Administrator. at New-MobyLinuxVM, : line 202

I hae also tried removing manually vhdx before docker start, its creating it, end result is the same.. Of course also tried start docker as an administrator..

qwebek avatar Aug 31 '16 21:08 qwebek

Thanks for the quick response. This is odd:

[00:11:56.585][HyperV         ][Info   ] Creating Switch: DockerNAT...
[00:11:59.029][HyperV         ][Info   ] Switch created.
[00:11:59.391][HyperV         ][Info   ] Set IP address on switch
[00:12:00.547][HyperV         ][Info   ] Creating dynamic VHD: C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx
[00:12:01.672][HyperV         ][Info   ] Creating VM MobyLinuxVM...
[00:12:05.944][HyperV         ][Info   ] Hyper-V is running
[00:12:05.946][HyperV         ][Info   ] Create
[00:12:05.947][PowerShell     ][Info   ] Run script with parameters: -Create True -SwitchSubnetAddress 10.0.75.0 -SwitchSubnetMaskSize 24 -CPUs 2 -Memory 2048 -IsoFile C:\Program Files\Docker\Docker\Resources\mobylinux.iso...
[00:12:06.283][HyperV         ][Info   ] Using existing Switch: DockerNAT
[00:12:06.341][HyperV         ][Info   ] Using existing Switch IP address
[00:12:06.355][HyperV         ][Info   ] VHD C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx already exists

The MobyLinux.ps1' -destroy should remove the VHDX file, but alas, the output from the logs says that the file still exists, thought other bits, like the switch, which are also removed by the script, are re-created.

Could you try again:

Stop-Service com.docker.service
& 'C:\Program Files\Docker\Docker\resources\MobyLinux.ps1' -destroy

and then double check that afterwards there is no C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx file? If there is, could you try to remove it manually and then restart the app?

Thanks

rn avatar Aug 31 '16 21:08 rn

The command is removing the vhdx file successfuly, that was one of the first things i was checking

It is s creating vhdx in that folder during docker startup, then somehow it looks to that folder again and reports that it aleready exist,

Another diagnostic E3B820D1-EFA6-4097-BA0E-BA68982EE30D/2016-09-01_02-04-23

qwebek avatar Aug 31 '16 23:08 qwebek

@qwebek thanks for providing the info. @dgageot could you also take a look if there might be an issue?

rn avatar Aug 31 '16 23:08 rn

@qwebek @rneugeba I have to say that I have no idea what's going on... What I can see is:

  • We try to start the VM which triggers a VM creation
  • The creation of the VM fails
  • We prefer to ignore this error and rather check that hyperv is running properly
  • It seems to run properly
  • So we try to create the VM once again which, of course, fails with the same error

But, I have no idea why it fails this way...

dgageot avatar Sep 05 '16 07:09 dgageot

Damn, could it be due to some permissions to some files or folders? Win 10 sometimes requires UAC permissions to some folders in program files, i don't know..

Maybe i can run try to run this separately? or whatever is creating VM

Run script with parameters: -Create True -SwitchSubnetAddress 10.0.75.0 -SwitchSubnetMaskSize 24 -CPUs 2 -Memory 2048 -IsoFile C:\Program Files\Docker\Docker\Resources\mobylinux.iso...

Thanks.

qwebek avatar Sep 05 '16 07:09 qwebek

@qwebek yes, trying to run this manually would be good. Something like:

  • exit the application
  • Stop-Service com.docker.service
  • .\MobyLinux.ps1' -destroy
  • check that the VHDX file is removed
  • .\MobyLinux.ps1 -Create True where the commands need to be executed from an elevated powershell and in the C:\Program Files\Docker\Docker\resources directory.

Otherwise, like @dgageot I'm running out of ideas of what be going on.

rn avatar Sep 05 '16 08:09 rn

Here is output of several commands, looks like the same error (

PS C:\Users\XXX> & 'C:\Program Files\Docker\Docker\resources\MobyLinux.ps1' -Create True C:\Program Files\Docker\Docker\resources\MobyLinux.ps1 : A positional parameter cannot be found that accepts argument 'True'. At line:1 char:1

  • & 'C:\Program Files\Docker\Docker\resources\MobyLinux.ps1' -Create Tr ...
  • - CategoryInfo          : InvalidArgument: (:) [MobyLinux.ps1], ParameterBindingException
    - FullyQualifiedErrorId : PositionalParameterNotFound,MobyLinux.ps1
    
    

PS C:\Users\XXX> & 'C:\Program Files\Docker\Docker\resources\MobyLinux.ps1' -Create Enabled workaround for Build 10586 VMSwitch issue Creating Switch: DockerNAT... Switch created. Set IP address on switch ISO file at .\mobylinux.iso does not exist At C:\Program Files\Docker\Docker\resources\MobyLinux.ps1:313 char:5

  • throw "$args"
    
  • ~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (ISO file at .\m... does not exist:String) [], RuntimeException
    • FullyQualifiedErrorId : ISO file at .\mobylinux.iso does not exist

    C:\program files\docker\docker\resources> ./MobyLinux.ps1 -Create Using existing Switch: DockerNAT Using existing Switch IP address Creating dynamic VHD: C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx Creating VM MobyLinuxVM... New-VM : Hyper-V encountered an error trying to access an object on computer 'XXX' because the object was not found. The object might have been deleted, or you might not have permission to perform the task. Verify that the Virtual Machine Management service on the computer is running. If the service is running, try to perform the task again by using Run as Administrator. At C:\program files\docker\docker\resources\MobyLinux.ps1:202 char:11

  • $vm = New-VM -Name $VmName -Generation 2 -VHDPath $vhd.Path -Swit ...
    
  •       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (:) [New-VM], VirtualizationException
    • FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.NewVM

qwebek avatar Sep 09 '16 06:09 qwebek

@qwebek Thanks for the update. As @rneugeba said, you should be in C:\Program Files\Docker\Docker\resources to run the commands. So let me refine the sequence of commands that you could run:

  • exit the application
  • Stop-Service com.docker.service
  • cd 'C:\Program Files\Docker\Docker\resources'
  • .\MobyLinux.ps1 -Destroy
  • check that the VHDX file (C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx) is removed
  • .\MobyLinux.ps1 -Create

dgageot avatar Sep 09 '16 07:09 dgageot

Hi David, Here is output

Maybe i need to check permissions to some folders where it tries to create VM ?

PS C:\program files\docker\docker\resources> Stop-Service com.docker.service PS C:\program files\docker\docker\resources> .\MobyLinux.ps1 -Destroy VM MobyLinuxVM does not exist Destroying Switch DockerNAT... Removing VM MobyLinuxVM... Delete VHD C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx PS C:\program files\docker\docker\resources> .\MobyLinux.ps1 -Create Enabled workaround for Build 10586 VMSwitch issue Creating Switch: DockerNAT... Switch created. Set IP address on switch Creating dynamic VHD: C:\Users\Public\Public Documents\Hyper-V\Virtual hard disks\MobyLinuxVM.vhdx Creating VM MobyLinuxVM... New-VM : Hyper-V encountered an error trying to access an object on computer 'XXX' because the object was not found. The object might have been deleted, or you might not have permission to perform the task. Verify that the Virtual Machine Management service on the computer is running. If the service is running, try to perform the task again by using Run as Administrator. At C:\program files\docker\docker\resources\MobyLinux.ps1:202 char:11

  • $vm = New-VM -Name $VmName -Generation 2 -VHDPath $vhd.Path -Swit ...
    
  •       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : ObjectNotFound: (:) [New-VM], VirtualizationException
    • FullyQualifiedErrorId : ObjectNotFound,Microsoft.HyperV.PowerShell.Commands.NewVM

qwebek avatar Sep 09 '16 07:09 qwebek

@qwebek Can you please try to create a new VM with default options using the Hyper-V Manager GUI? I'm betting on a corrupted Hyper-V installation like described here: https://social.technet.microsoft.com/Forums/en-US/b7affd2b-e27a-40e1-bbdc-38a48e757a60/corrupted-hyperv-environment?forum=winserverhyperv

If it's case, I'd run .\MobyLinux.ps1 -Destroy then go to Add/Remove Windows Features, remove all Hyper-V features, reboot, Add Hyper-V back, and reboot and try the previous commands again.

capture

dgageot avatar Sep 09 '16 07:09 dgageot

OO created and started VM with default params

virtual_machine

virtual_machine_1

qwebek avatar Sep 09 '16 08:09 qwebek

In that post you gave, the guy is describing the situation when HyperV fails to create VM when using existing vhdx, i will try to create new VM through HyperV UI using .vhdx created by docker, will update after minute

qwebek avatar Sep 09 '16 08:09 qwebek

Ok, its failing as described in above post link

virtual_machine_2

qwebek avatar Sep 09 '16 08:09 qwebek

Multiple disable-reboot-enable-reboot Hyper-V doesn't help ( It just cannot create VM using exisitng vhdx I also didint find a way to reinstall hyper-v except of that way that is done through turn windows features.. It looks like dead end)

qwebek avatar Sep 09 '16 09:09 qwebek

Few udpates

I was able to create Vargrant machine and was able to connect to it using ssh as described by @ericis in Cannot run Docker after reinstall #76

Install vagrant
Create a "Vagrantfile" in an empty directory with the content

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "hashicorp/precise64"
end
In a command window with the current working directory pointed to the directory above with the "Vagrantfile", run vagrant up --provider=hyperv

By the way, I was installing vargrant not to program files but some not windows system folders

Also, I was also able to manually create new VM in Hyper-V with new vhdx that is stored in users/user/workspace and then i have changed its settings by right clicking in Hyper-v and changed vhdx file to MobyLinuxVM created by docker and changed network adapter to DockerNAT Then i have tried to start this VM from Hyper-V UI and it started fine, showing expected message that no operating system is installed

qwebek avatar Sep 18 '16 11:09 qwebek

I'm running Windows 10 Pro version 1607 and I'm having a similar issue. The Create process successfully creates the virtual switch, but fails when creating the VM with the error message "Unable to execute Start: Unable to create: Hyper-V encountered an error trying to access an object on computer 'XXXXX' because the object was not found."

Because the switch was being successfully created, I focused on the New-MobyLinuxVM function in the MobyLinux.ps1 script. I manually stepped through each line of the function trying to track down exactly where the error was coming from.

The first issue was the following line:

$vm = New-VM -Name $VmName -Generation 2 -VHDPath $vhd.Path -SwitchName $SwitchName

The only way I could get this line of code to run is if I removed the -VHDPath parameter. I was, however, able to get past this step by replacing it with two lines of code... first creating the VM without a VHD and then added it.

$vm = New-VM -Name $VmName -Generation 2 -SwitchName $SwitchName -NoVHD

$vm | Add-VMHardDiskDrive -Path $vhd.Path

The process failed again though, so I kept going through the code and ran into another snag with the following line:

$vm | Set-VMFirmware -EnableSecureBoot Off -BootOrder $bootDisk

What I don't understand here is that this SHOULD work according to Microsoft's own documentation. I was, however, able to get past this point and successfully create the VM by replacing the line of code above with the following lines:

$bootOrder = ($vm | Get-VMFirmware).BootOrder | Where-Object {$_.FirmwarePath -like "*$($bootDisk.ControllerType)($($bootDisk.ControllerNumber),$($bootDisk.ControllerLocation))"}

$vm | Set-VMFirmware -EnableSecureBoot Off -BootOrder $bootOrder

What I'm not certain about is if this is just some strange oddity with my system or some bug/change introduced by a Windows update.

wamonroe avatar Sep 29 '16 20:09 wamonroe

Hi, thanks for info I have tracked this down to the issue in hyper-v: go to hyper-v manager and try to create gen2 vm pointing to some vhd that you have created beforehand, when i finish this kind of vm through wizard it is failing with error after you press finish

Ihave created manually vm named as docker needs and attached to it mobylinux vhdx and that seem to run fine - but doxker ifnores that vm

I intend to refer to admins to roll over windows update that is >1511 or will make reinstall, not sure what else can be done here

qwebek avatar Sep 29 '16 22:09 qwebek