docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.86k stars 289 forks source link

Hyper-V was unable to find a virtual switch with name "DockerNAT" #2090

Closed mathieubrd closed 4 years ago

mathieubrd commented 6 years ago

Expected behavior

Docker daemon is running

Actual behavior

An error occur when starting the Docker daemon. Error is Hyper-V was unable to find a virtual switch with name "DockerNAT".

Information

I tried to disable Hyper-V, remove all the Hyper-V virtual adapters, uninstall Docker and reinstall it, same problem.

Steps to reproduce the behavior

  1. Install Docker
  2. Run Docker
  3. Accept to enable Hyper-V feature and let Docker restart the PC.
  4. After restart, Docker tries to start and fail with the logs below.

Logs

Version: 18.03.1-ce-win65 (17513)
Channel: stable
Sha1: 93354b38bd7210badafff8e0ce1f0be9a465be83
Started on: 2018/06/07 13:58:54.549
Resources: C:\Program Files\Docker\Docker\Resources
OS: Windows 10 Pro
Edition: Professional
Id: 1803
Build: 17134
BuildLabName: 17134.1.amd64fre.rs4_release.180410-1804
File: d:\Profiles\mbrochard\AppData\Local\Docker\log.txt
CommandLine: "C:\Program Files\Docker\Docker\Docker for Windows.exe" 
You can send feedback, including this log file, at https://github.com/docker/for-win/issues
[13:58:55.531][GUI            ][Info   ] Starting...
[13:59:00.828][Tracking       ][Info   ] Crash report and usage statistics are enabled
[13:59:00.835][SegmentApi     ][Info   ] Usage statistic: appLaunched
[13:59:02.120][SegmentApi     ][Info   ] Usage statistic: heartbeat
[13:59:02.134][SegmentApi     ][Info   ] Usage statistic: Identify
[13:59:02.501][Notifications  ][Info   ] Docker is starting...
[13:59:02.619][NamedPipeClient][Info   ] Sending Version()...
[13:59:02.663][NamedPipeClient][Info   ] Received response for Version
[13:58:20.480][BackendServer  ][Info   ] Started
[13:59:02.659][NamedPipeServer][Info   ] Version()
[13:59:02.674][NamedPipeClient][Info   ] Sending Start(Linux, Docker.Core.Settings, Docker.Core.DaemonOptions)...
[13:59:02.660][NamedPipeServer][Info   ] Version done in 00:00:00.0007196.
[13:59:02.690][NamedPipeServer][Info   ] Start(Linux, Docker.Core.Settings, Docker.Core.DaemonOptions)
[13:59:02.697][PowerMode      ][Info   ] Stop
[13:59:02.763][HyperV         ][Info   ] Stop
[13:59:02.825][PowerShell     ][Info   ] Run script with parameters: -Stop True...
[13:59:02.850][PowerShell     ][Info   ] Creating a Runspace Pool...
[13:59:06.039][PowerShell     ][Info   ] Runspace Pool created (Min=1, Max=2)
[13:59:06.321][HyperV         ][Info   ] Script started at 13:59:06.311
[13:59:13.253][HyperV         ][Info   ] Module loaded at 13:59:13.253
[13:59:13.675][HyperV         ][Info   ] VM MobyLinuxVM does not exist
[13:59:13.677][HyperV         ][Debug  ] [stop] took 00:00:10.9000052 to run
[13:59:13.677][OptimizeDisk   ][Info   ] Optimize
[13:59:13.678][PowerShell     ][Info   ] Run script...
[13:59:13.719][Moby           ][Info   ] Stop
[13:59:13.747][HyperVGuids    ][Info   ] Installing GUIDs...
[13:59:13.747][PowerMode      ][Info   ] Start
[13:59:13.753][HyperV         ][Info   ] Create
[13:59:13.755][PowerShell     ][Info   ] Run script with parameters: -Create True -VhdPathOverride  -VhdSize 64424509440 -SwitchSubnetAddress 10.0.75.0 -SwitchSubnetMaskSize 24 -CPUs 2 -Memory 2048 -IsoFile C:\Program Files\Docker\Docker\Resources\docker-for-win.iso...
[13:59:13.763][Firewall       ][Info   ] Removing all existing rules...
[13:59:13.763][HyperVGuids    ][Info   ] GUIDs installed
[13:59:13.766][HyperV         ][Info   ] Script started at 13:59:13.766
[13:59:13.791][HyperV         ][Info   ] Module loaded at 13:59:13.791
[13:59:13.803][Firewall       ][Info   ] All existing rules are removed.
[13:59:13.804][Firewall       ][Info   ] Opening ports for C:\Program Files\Docker\Docker\Resources\com.docker.proxy.exe...
[13:59:13.822][Firewall       ][Info   ] Opening ports for SMB...
[13:59:13.849][Firewall       ][Info   ] Ports are opened
[13:59:13.949][HyperV         ][Info   ] Creating Switch: DockerNAT...
[13:59:57.430][Linux          ][Error  ] Failed to start: Unable to create: L’exécution de la commande s’est arrêtée, car la variable de préférence « ErrorActionPreference » ou le paramètre courant a la valeur Stop : Hyper-V n'a trouvé aucun commutateur virtuel portant le nom « DockerNAT ».
à New-Switch, <Aucun fichier> : ligne 117
à <ScriptBlock>, <Aucun fichier> : ligne 394. Let's retry
[13:59:57.667][Installer      ][Info   ] Checking for features: Hyper-V, Containers
[13:59:57.668][PowerShell     ][Info   ] Run script...
[14:00:02.593][PowerShell     ][Info   ] Run script...
[14:00:04.726][PowerShell     ][Info   ] Run script...
[14:00:07.027][PowerShell     ][Info   ] Run script...
[14:00:09.293][Installer      ][Info   ] Features installed
[14:00:09.327][HyperV         ][Info   ] Hyper-V is running
[14:00:09.327][PowerMode      ][Info   ] Stop
[14:00:09.327][HyperV         ][Info   ] Stop
[14:00:09.328][PowerShell     ][Info   ] Run script with parameters: -Stop True...
[14:00:09.337][HyperV         ][Info   ] Script started at 14:00:09.337
[14:00:09.349][HyperV         ][Info   ] Module loaded at 14:00:09.349
[14:00:09.357][HyperV         ][Info   ] VM MobyLinuxVM does not exist
[14:00:09.358][HyperV         ][Debug  ] [stop] took 00:00:00.0309995 to run
[14:00:09.358][OptimizeDisk   ][Info   ] Optimize
[14:00:09.358][PowerShell     ][Info   ] Run script...
[14:00:09.366][Moby           ][Info   ] Stop
[14:00:09.374][HyperV         ][Info   ] Destroy
[14:00:09.375][PowerShell     ][Info   ] Run script with parameters: -Destroy True -KeepVolume True...
[14:00:09.381][HyperV         ][Info   ] Script started at 14:00:09.381
[14:00:09.393][HyperV         ][Info   ] Module loaded at 14:00:09.393
[14:00:09.400][HyperV         ][Info   ] VM MobyLinuxVM does not exist
[14:00:09.403][HyperV         ][Info   ] Destroying Switch DockerNAT...
[14:00:09.419][HyperV         ][Info   ] Removing VM MobyLinuxVM...
[14:00:09.430][HyperV         ][Debug  ] [destroy] took 00:00:00.0555348 to run
[14:00:09.430][Firewall       ][Info   ] Closing ports...
[14:00:09.430][Firewall       ][Info   ] Removing all existing rules...
[14:00:09.491][Firewall       ][Info   ] All existing rules are removed.
[14:00:09.491][Firewall       ][Info   ] Ports are closed
[14:00:09.491][HyperVGuids    ][Info   ] Removing GUIDs...
[14:00:09.494][HyperVGuids    ][Info   ] GUIDs removed
[14:00:09.494][HyperV         ][Info   ] Create
[14:00:09.494][PowerShell     ][Info   ] Run script with parameters: -Create True -VhdPathOverride  -VhdSize 64424509440 -SwitchSubnetAddress 10.0.75.0 -SwitchSubnetMaskSize 24 -CPUs 2 -Memory 2048 -IsoFile C:\Program Files\Docker\Docker\Resources\docker-for-win.iso...
[14:00:09.503][HyperV         ][Info   ] Script started at 14:00:09.503
[14:00:09.529][HyperV         ][Info   ] Module loaded at 14:00:09.529
[14:00:09.547][HyperV         ][Info   ] Creating Switch: DockerNAT...
[14:00:40.862][NamedPipeServer][Error  ] Unable to execute Start: Unable to create: L’exécution de la commande s’est arrêtée, car la variable de préférence « ErrorActionPreference » ou le paramètre courant a la valeur Stop : Hyper-V n'a trouvé aucun commutateur virtuel portant le nom « DockerNAT ».
à New-Switch, <Aucun fichier> : ligne 117
à <ScriptBlock>, <Aucun fichier> : ligne 394    à Docker.Backend.HyperV.RunScript(String action, Dictionary`2 parameters) dans C:\gopath\src\github.com\docker\pinata\win\src\Docker.Backend\HyperV.cs:ligne 183
   à Docker.Backend.ContainerEngine.Linux.Start(Settings settings, String daemonOptions) dans C:\gopath\src\github.com\docker\pinata\win\src\Docker.Backend\ContainerEngine\Linux.cs:ligne 111
[14:00:41.060][NamedPipeClient][Error  ] Unable to send Start: Unable to create: L’exécution de la commande s’est arrêtée, car la variable de préférence « ErrorActionPreference » ou le paramètre courant a la valeur Stop : Hyper-V n'a trouvé aucun commutateur virtuel portant le nom « DockerNAT ».
à New-Switch, <Aucun fichier> : ligne 117
à <ScriptBlock>, <Aucun fichier> : ligne 394
[14:00:41.062][Notifications  ][Error  ] Unable to create: L’exécution de la commande s’est arrêtée, car la variable de préférence « ErrorActionPreference » ou le paramètre courant a la valeur Stop : Hyper-V n'a trouvé aucun commutateur virtuel portant le nom « DockerNAT ».
à New-Switch, <Aucun fichier> : ligne 117
à <ScriptBlock>, <Aucun fichier> : ligne 394
[14:01:00.214][ErrorReportWindow][Info   ] Open logs
jasonbivins commented 6 years ago

@mathieubrochard Will it allow you to create the switch manually?

powershell -ExecutionPolicy ByPass -File "C:\ProgramFiles\Docker\Docker\resources\MobyLinux.ps1" -create -switchname DockerNAT

mathieubrd commented 6 years ago

Hi @jasonbivins and thank you for your answer. Here is the result of the command:

.\MobyLinux.ps1 -create -switchname DockerNAT
Script started at 09:14:02.253
Module loaded at 09:14:04.507
Creating Switch: DockerNAT...
Hyper-V\Get-VMNetworkAdapter : Hyper-V was unable to find a virtual switch with name « DockerNAT ».
At character C:\Program Files\Docker\Docker\resources\MobyLinux.ps1:117 : 25
+ ... etAdapter = Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName $S ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument : (DockerNAT:String) [Get-VMNetworkAdapter], VirtualizationException
    + FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.GetVMNetworkAdapter

Also, I tried to create the DockerNAT virtual switch manually using Hyper-V and here is the error: hyper-v_dockernat_error The issue seems to be related with Hyper-V, not Docker.

thomasgassmann commented 6 years ago

I'm facing the same problem. Are there any updates on this issue? I have already tried uninstalling Trend Micro, uninstalling Check Point Mobile VPN, upgrading Check Point Mobile VPN and reinstalling Hyper V (as mentioned in #324). Yet Docker is still unable to create the virtual switch.

pabloperich commented 6 years ago

The same problem. Uninstalling CheckPoint VPN fixed it.

thomasgassmann commented 6 years ago

@pabloperich Did you do anything else concerning Hyper-V after uninstalling Check Point VPN? Unfortunately uninstalling it, didn't work for me, even after rebooting and deleting the network adapter.

pabloperich commented 6 years ago

@ThomasGassmann I didn't change anything concerning Hyper-V, but after unistalling Check Point VPN, I had to restore factory settings for Docker. After that, I checked Hyper-V Manager and it had the MobyLinuxVM and the DockerNAT again.

thomasgassmann commented 6 years ago

Uninstalling Check Point VPN didn't work for me either. Is there any other solution known to this problem? When trying to create a virtual switch manually, I get the following message: image I've tried reinstalling Hyper-V multiple times... trying to repair Hyper-V through MOFCOMP. None of it worked.

drou7 commented 6 years ago

Same problem here... Any fix ?

coatsnmore commented 6 years ago

Same problem. Windows 10 Pro Version 1803. Docker Version 18.03.1-ce-win65 (17513).

When I run powershell -ExecutionPolicy ByPass -File "C:\Program Files\Docker\Docker\resources\MobyLinux.ps1" -create -switchname DockerNAT it also gives me the same result.

PS C:\WINDOWS\system32> powershell -ExecutionPolicy ByPass -File "C:\Program Files\Docker\Docker\resources\MobyLinux.ps1
" -create -switchname DockerNAT
Script started at 23:39:59.530
Module loaded at 23:40:01.159
Creating Switch: DockerNAT...
Switch created.
New-NetIPAddress : The object already exists.
At C:\Program Files\Docker\Docker\resources\MobyLinux.ps1:152 char:23
+ ... rkAdapter | New-NetIPAddress -AddressFamily IPv4 -IPAddress $switchAd ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (MSFT_NetIPAddress:ROOT/StandardCimv2/MSFT_NetIPAddress) [New-NetIPAddress
   ], CimException
    + FullyQualifiedErrorId : Windows System Error 5010,New-NetIPAddress
drou7 commented 6 years ago

I have exactly the same problem as mathieubrochard. I think this is purely a HyperV problem.

PS C:\Program Files\Docker\Docker\resources> powershell -ExecutionPolicy ByPass -File "C:\Program Files\Docker\Docker\resources\MobyLinux.ps1" -create -switchname DockerNAT
Script started at 10:23:26.565
Module loaded at 10:23:28.446

Creating Switch: DockerNAT...
Hyper-V\Get-VMNetworkAdapter : Hyper-V was unable to find a virtual switch with name « DockerNAT ».
At character C:\Program Files\Docker\Docker\resources\MobyLinux.ps1:117 : 25
+ ... etAdapter = Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName $S ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument : (DockerNAT:String) [Get-VMNetworkAdapter], VirtualizationException
    + FullyQualifiedErrorId : InvalidParameter,Microsoft.HyperV.PowerShell.Commands.GetVMNetworkAdapter
bifocalpirate commented 6 years ago

@drou7 I recently installed a ton of windows updates and this exact issue popped up out of nowhere. What worked for me is I uninstalled Check Point VPN, then ran the powershell -Create script which then completed succesfully. I'll have to re-install Check Point later though. For the moment my docker issue has been resolved.

drou7 commented 6 years ago

I don't know why, but today, when I started my PC Docker is now running and work well. This is whay I done yesterday:

And now today, it works... I'm scared, I don't want to restart my PC now.

EDIT : After a restart, the same problem back...

drou7 commented 6 years ago

It works well now. It was Trend OfficeScan.

If you have it : You must disable 'Protect OfficeScan agent registry keys' and 'Protect OfficeScan agent processes' Docker works perfectly now.

All errors with 0x80070005 means the access is denied. In this case, Hyper-V is not allowed to edit your network card. You must find which programm is blocking Hyper-V.

docker-robott commented 6 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

ddabberu commented 6 years ago

/remove-lifecycle stale [19:09:58.387][Linux ][Error ] Failed to start: Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Hyper-V was unable to find a virtual switch with name "DockerNAT". at New-Switch, : line 118 at , : line 400. Let's retry [19:09:58.403][HyperV ][Info ] Starting Hyper-V Virtual Machine Management service [19:09:58.600][NPS ][Info ] NPS last local survey date: 10/7/2018 12:44:14 AM +00:00 [19:09:59.545][HyperV ][Info ] Hyper-V is running [19:09:59.545][PowerMode ][Info ] Stop [19:09:59.545][HyperV ][Info ] Stop [19:09:59.545][PowerShell ][Info ] Run script with parameters: -Stop True... [19:09:59.596][HyperV ][Info ] Script started at 19:09:59.596 [19:09:59.609][HyperV ][Info ] Module loaded at 19:09:59.609 [19:09:59.632][HyperV ][Info ] VM MobyLinuxVM does not exist [19:09:59.638][HyperV ][Debug ] [stop] took 00:00:00.0935096 to run [19:09:59.638][OptimizeDisk ][Info ] Optimize [19:09:59.638][PowerShell ][Info ] Run script... [19:09:59.651][Moby ][Info ] Stop [19:09:59.654][HyperV ][Info ] Destroy [19:09:59.655][PowerShell ][Info ] Run script with parameters: -Destroy True -KeepVolume True... [19:09:59.676][HyperV ][Info ] Script started at 19:09:59.676 [19:09:59.685][HyperV ][Info ] Module loaded at 19:09:59.685 [19:09:59.694][HyperV ][Info ] VM MobyLinuxVM does not exist [19:09:59.697][HyperV ][Info ] Destroying Switch DockerNAT... [19:09:59.712][HyperV ][Info ] Removing VM MobyLinuxVM... [19:09:59.722][HyperV ][Debug ] [destroy] took 00:00:00.0673460 to run [19:09:59.722][Firewall ][Info ] Closing ports... [19:09:59.722][Firewall ][Info ] Removing all existing rules... [19:09:59.858][Firewall ][Info ] All existing rules are removed. [19:09:59.858][Firewall ][Info ] Ports are closed [19:09:59.858][HyperVGuids ][Info ] Removing GUIDs... [19:09:59.860][HyperVGuids ][Info ] GUIDs removed [19:09:59.860][HyperV ][Info ] Create [19:09:59.861][PowerShell ][Info ] Run script with parameters: -Create True -VhdPathOverride -VhdSize 64000000000 -SwitchSubnetAddress 10.0.75.0 -SwitchSubnetMaskSize 24 -CPUs 2 -Memory 2048 -IsoFile C:\Program Files\Docker\Docker\Resources\docker-for-win.iso... [19:09:59.892][HyperV ][Info ] Script started at 19:09:59.892 [19:09:59.903][HyperV ][Info ] Module loaded at 19:09:59.903 [19:09:59.940][HyperV ][Info ] Creating Switch: DockerNAT... [19:09:59.964][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 was unable to find a virtual switch with name "DockerNAT". at New-Switch, : line 118 at , : line 400 at Docker.Backend.HyperV.RunScript(String action, Dictionary`2 parameters) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Backend\HyperV.cs:line 188 at Docker.Backend.HyperV.Create(Settings settings) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Backend\HyperV.cs:line 118 at Docker.Backend.ContainerEngine.Linux.Start(Settings settings, String daemonOptions) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Backend\ContainerEngine\Linux.cs:line 117 [19:10:00.032][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 was unable to find a virtual switch with name "DockerNAT". at New-Switch, : line 118 at , : line 400 [19:10:00.032][Notifications ][Error ] Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Hyper-V was unable to find a virtual switch with name "DockerNAT". at New-Switch, : line 118 at , : line 400 [19:10:00.054][NamedPipeClient][Info ] Sending Version()... [19:10:00.055][NamedPipeClient][Info ] Received response for Version [19:10:00.055][NamedPipeClient][Info ] Sending GatherDiagnostics(-path C:\Users\Admin\AppData\Local\Temp\ gather -id C12DEA52-BEC4-4CF1-894A-C09CC70F8586/20181007191000, C:\Users\Admin\AppData\Local\Temp\C12DEA52-BEC4-4CF1-894A-C09CC70F8586/20181007191000.zip)... [19:10:00.055][NamedPipeServer][Info ] Version() [19:10:00.055][NamedPipeServer][Info ] Version done in 00:00:00. [19:10:00.056][NamedPipeServer][Info ] GatherDiagnostics(-path C:\Users\Admin\AppData\Local\Temp\ gather -id C12DEA52-BEC4-4CF1-894A-C09CC70F8586/20181007191000, C:\Users\Admin\AppData\Local\Temp\C12DEA52-BEC4-4CF1-894A-C09CC70F8586/20181007191000.zip) [19:10:10.230][ErrorReportWindow][Info ] Open logs

ghost commented 5 years ago

I am having this issue as well I had to uninstall Zone Aarm, then it worked. I reinstalled it and it worked for a few days (I had to switch firewall off before starting Docker). Now it's acting up again after today's latest update

infernalsirius commented 5 years ago

Same issue here, but behind a corporate network. I will post the details if there's anything that could help others.

infernalsirius commented 5 years ago

The issue seems to be with the service's right to logon that is given through a GPO policy. In some case, the right does not seems to be applied.

http://ventej.blogspot.com/2013/09/hyperv-virtual-mahine-creation-error.html

One way to fix this is to restart the Hyper-V management service:

# Done from an admin shell 
net stop vmms
net start vmms

Restart Docker and it should be able to create the mobylinux VM now.

sgtoj commented 5 years ago

Although I have Trend Micro installed and had the same error, I was able to resolve this issue by running a Microsoft Easy Fix wizard and rebooting my system.

https://support.microsoft.com/en-us/help/3101106/you-cannot-create-a-hyper-v-virtual-switch-on-64-bit-versions-of-windo

jsam2412 commented 5 years ago

@infernalsirius - Thanks, this worked for me.

Hurray....

Try running these commands and restart docker. This worked for me.

# Done from an admin shell 
net stop vmms
net start vmms
jsam2412 commented 5 years ago

The issue seems to be with the service's right to logon that is given through a GPO policy. In some case, the right does not seems to be applied.

http://ventej.blogspot.com/2013/09/hyperv-virtual-mahine-creation-error.html

One way to fix this is to restart the Hyper-V management service:

# Done from an admin shell 
net stop vmms
net start vmms

Restart Docker and it should be able to create the mobylinux VM now.

This worked like a charm.

ghost commented 5 years ago

For the ones that use Trend Micro as their antivirus, the solution is here: https://success.trendmicro.com/solution/1120119-unable-to-create-hyper-v-vswitch-on-a-windows-10-machine-with-officescan

More generally, you should do this as well as it's is a pre-requirements regardless of the antivirus used:

https://support.microsoft.com/en-us/help/3105657/recommended-antivirus-exclusions-for-hyper-v-hosts

Since disabling an antivirus is not an option nor a solution, this permanent fix would need to be applied. Otherwise, when you restart or stop/start the Docker service, it will destroy and recreate the v-switch and you'll get the same error again.

vivekmids commented 5 years ago

After working flawlessly for several days, Docker started giving me this error. I did not install any software and do not use a VPN or antivirus (except Windows Defender).

I restarted my pc and have restarted the vmms service. That did not help fix this issue. Here is a portion of the log file:

[23:22:36.571][PowerShell ][Info ] Run script with parameters: -Create True -VhdPathOverride -VhdSize 64000000000 -SwitchSubnetAddress 10.0.75.0 -SwitchSubnetMaskSize 24 -CPUs 2 -Memory 2048 -IsoFile C:\Program Files\Docker\Docker\Resources\docker-for-win.iso [23:22:36.571][Firewall ][Info ] Removing all existing rules... [23:22:36.573][HyperVGuids ][Info ] GUIDs installed [23:22:36.593][HyperV ][Info ] Script started at 23:22:36.593 [23:22:36.597][Firewall ][Info ] All existing rules are removed. [23:22:36.597][Firewall ][Info ] Opening ports for C:\Program Files\Docker\Docker\Resources\com.docker.proxy.exe... [23:22:36.603][HyperV ][Info ] Modules loaded at 23:22:36.603 [23:22:36.603][Firewall ][Info ] Opening ports for SMB... [23:22:36.610][Firewall ][Info ] Ports are opened [23:22:36.624][HyperV ][Info ] Creating Switch: DockerNAT... [23:22:36.791][NPS ][Info ] NPS user ceated on: 5/20/2019 3:30:20 PM -07:00, last survey: 1/1/0001 12:00:00 AM +00:00 [23:23:07.868][Linux ][Error ] Failed to start: Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Hyper-V was unable to find a virtual switch with name "DockerNAT". at New-Switch, : line 121 at , : line 411. Let's retry [23:23:07.884][HyperV ][Info ] Hyper-V is running [23:23:07.884][PowerMode ][Info ] Stop [23:23:07.884][HyperV ][Info ] Stop [23:23:07.884][PowerShell ][Info ] Run script with parameters: -Stop True [23:23:07.899][HyperV ][Info ] Script started at 23:23:07.899 [23:23:07.905][HyperV ][Info ] Modules loaded at 23:23:07.905 [23:23:07.913][HyperV ][Info ] VM MobyLinuxVM does not exist [23:23:07.913][HyperV ][Debug ] [stop] took 00:00:00.0288536 to run [23:23:07.913][OptimizeDisk ][Info ] Optimize [23:23:07.913][PowerShell ][Info ] Run script... [23:23:07.920][Moby ][Info ] Stop [23:23:07.924][HyperV ][Info ] Destroy [23:23:07.924][PowerShell ][Info ] Run script with parameters: -Destroy True -KeepVolume True [23:23:07.938][HyperV ][Info ] Script started at 23:23:07.938 [23:23:07.949][HyperV ][Info ] Modules loaded at 23:23:07.949 [23:23:07.957][HyperV ][Info ] VM MobyLinuxVM does not exist [23:23:07.957][HyperV ][Info ] Destroying Switch DockerNAT... [23:23:07.969][HyperV ][Info ] Removing VM MobyLinuxVM... [23:23:07.974][HyperV ][Debug ] [destroy] took 00:00:00.0502969 to run [23:23:07.974][Firewall ][Info ] Closing ports... [23:23:07.974][Firewall ][Info ] Removing all existing rules... [23:23:08.033][Firewall ][Info ] All existing rules are removed. [23:23:08.033][Firewall ][Info ] Ports are closed [23:23:08.033][HyperVGuids ][Info ] Removing GUIDs... [23:23:08.034][HyperVGuids ][Info ] GUIDs removed [23:23:08.034][HyperV ][Info ] Create [23:23:08.034][PowerShell ][Info ] Run script with parameters: -Create True -VhdPathOverride -VhdSize 64000000000 -SwitchSubnetAddress 10.0.75.0 -SwitchSubnetMaskSize 24 -CPUs 2 -Memory 2048 -IsoFile C:\Program Files\Docker\Docker\Resources\docker-for-win.iso [23:23:08.051][HyperV ][Info ] Script started at 23:23:08.051 [23:23:08.064][HyperV ][Info ] Modules loaded at 23:23:08.063 [23:23:08.081][HyperV ][Info ] Creating Switch: DockerNAT... [23:23:37.237][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 was unable to find a virtual switch with name "DockerNAT". at New-Switch, : line 121 at , : line 411 at Docker.Backend.HyperV.RunScript(String action, Dictionary`2 parameters) at Docker.Backend.HyperV.Create(Settings settings) at Docker.Backend.ContainerEngine.Linux.Start(Settings settings, String daemonOptions) [23:23:37.279][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 was unable to find a virtual switch with name "DockerNAT". at New-Switch, : line 121 at , : line 411 [23:23:37.280][Notifications ][Error ] Unable to create: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Hyper-V was unable to find a virtual switch with name "DockerNAT". at New-Switch, : line 121 at , : line 411

sxmartin commented 5 years ago

same here.. Were you able to find the root cause?

vivekmids commented 5 years ago

I couldn’t get it to work on windows. I installed a Ubuntu vm and setup my docket there.

On Mon, Jun 3, 2019 at 12:31 PM sxmartin notifications@github.com wrote:

same here.. Were you able to find the root cause?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/docker/for-win/issues/2090?email_source=notifications&email_token=AJNHYEU4FAASJ3MB5AEAD4TPYVBN3A5CNFSM4FDZETOKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWZ6WPA#issuecomment-498330428, or mute the thread https://github.com/notifications/unsubscribe-auth/AJNHYEQ2XB45QLM7WMT4E4TPYVBN3ANCNFSM4FDZETOA .

-- Regards Vivek

rachmadideni commented 5 years ago

hi guys i got the same error here . make sure "Hyper-v extensible switch" is checked and click ok. image

Albert221 commented 5 years ago

net stop vmms net start vmms

that indeed help, but not fully:

PS C:\WINDOWS\system32> powershell -ExecutionPolicy ByPass -File "C:\Program Files\Docker\Docker\resources\MobyLinux.ps1" -create -switchname DockerNAT
Script started at 14:49:02.996
Modules loaded at 14:49:04.137
Creating Switch: DockerNAT...
Switch created.
Set IP address on switch
ISO file at .\docker-for-win.iso does not exist
At C:\Program Files\Docker\Docker\resources\MobyLinux.ps1:402 char:5
+     throw "$args"
+     ~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (ISO file at .\d... does not exist:String) [], RuntimeException
    + FullyQualifiedErrorId : ISO file at .\docker-for-win.iso does not exist

after that I resetted Docker to factory defaults and it now works!

Jitsusama commented 5 years ago

FYI; if you're running Trend Micro OfficeScan; see this article: https://success.trendmicro.com/solution/1120119-unable-to-create-hyper-v-vswitch-on-a-windows-10-machine-with-officescan

Once my IT department followed through with its recommendations, I was off to the races. If you use some other AV software; check out this article by Microsoft: https://support.microsoft.com/en-us/help/3105657/recommended-antivirus-exclusions-for-hyper-v-hosts

It appears that various AV programs have issues with Hyper-V on Windows due to how it works, and Microsoft recommends various actions for AV vendors to take in order to allow them to co-exist.

gnanasundar commented 5 years ago

In my case, after adding the Docker folder to Trend Micro exclusions it worked.

stewartadam commented 4 years ago

I'm by no means an expert on Hyper-V internals, but looking on the web a common issue that causes the symptoms described in this thread is broken WMI registrations, which you can fix by running [as admin]:

MOFCOMP %SYSTEMROOT%\System32\WindowsVirtualization.V2.mof

I also have a hunch this is related to running Docker under Azure AD or domain accounts, as I've had issues with that in the past and creating a DockerNAT switch manually through the Hyper-V machine manager was giving me errors about accessing objects on the MACHINENAME domain.

For those having this issue on Azure AD or Domain accounts, try:

  1. Create a local account from the Windows 10 settings app
  2. Set the account type to Administrator
  3. Go to group management and add the new local user to the docker-users group
  4. Reboot and do not let Windows Hello sign in to your domain account -- be sure to immediately click Other User and sign-in as the local account
  5. Start Docker and switch to Linux containers

This should successfully create the DockerNAT switch for you, at which point you may now reboot & sign-in to domain and continue to use docker.

sirudog commented 4 years ago

None of these worked for me. I have tried countless of possible solutions reported by others. In the end, this rather old post helped: https://forums.docker.com/t/latest-failed-docker-update-makes-hyper-v-unable-to-create-virtual-ethernet-switch-0x80041002/44109

So to fix the issue:

  1. uninstall crippled Docker for Windows
  2. remove both Hyper-V and Containers features then reboot
  3. add Hyper-V and Containers features back then reboot
  4. reinstall Docker for Windows then start it

Hope this helps

fakabbir commented 4 years ago

Tried uncheck and check back after restart worked for me: https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v

justinyng commented 4 years ago

Uncheck and rechecking the features as above worked for me! (also, I didn't have to uninstall and re-installed docker) https://github.com/docker/for-win/issues/2090#issuecomment-567590149

Mohamed-rabbaoui commented 4 years ago

Just uncheck than check Hyper-V in windows features than restart ( it works for me ) https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v

ArielJurkowski commented 4 years ago

None of these worked for me. I have tried countless of possible solutions reported by others. In the end, this rather old post helped: https://forums.docker.com/t/latest-failed-docker-update-makes-hyper-v-unable-to-create-virtual-ethernet-switch-0x80041002/44109

So to fix the issue:

1. uninstall crippled Docker for Windows

2. remove both `Hyper-V` and `Containers` features then reboot

3. add `Hyper-V` and `Containers` features back then reboot

4. reinstall Docker for Windows then start it

Hope this helps

This worked for me. Thank you so much.

docker-robott commented 4 years ago

Issues go stale after 90 days of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

stewartadam commented 4 years ago

/remove-lifecycle stale

docker-robott commented 4 years ago

Issues go stale after 90 days of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30 days of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

docker-robott commented 3 years ago

Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.

If you have found a problem that seems similar to this, please open a new issue.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle locked