Docker – Fails to create container on Windows 10 – Error response from daemon container..encountered an error during start

Thought to share findings that came across on fixing the below issue. May be it can help someone while working in docker with Windows 10.

 Issue: Unable to create docker container on Windows 10 Version 1607

Error response from daemon container..encountered an error during start

Workaround: docker run -it –rm –net=none microsoft/nanoserver cmd

 Finding & Cause:

Gather the network trace using command – netsh trace start globallevel=7 provider=Microsoft-Windows-Host-Network-Service  report=di on viewing the logs we found the message “HNS failed to create vmswitch port with error ‘0x80070003’, switch id = ‘c502a850-2f21-4d55-9879-14cc66f69193’, port id = ‘e2e3b5ba-1de9-4650-a0e0-50276c0e2cb8’ and type = ‘Value_3’” 

Checked the VMSwitch found the NAT switch is missing  ( Normally deleting and re-creating vmswitch based upon Hyperv VM’s requirement as it’s in Lab)

get-vmswitch

Checked the Container network and found the NAT network is in second order

get-containernetwork

Solution: Follow the below steps that will help you to get rid of the error

Get-containernetwork | Remove-Containernetwork -force

Restart-service hns

Restart-service docker

Get-containernetwork

Get-vmswitch

Get-netnat

And finally created the container it worked successfully

Lesson Learnt: Whenever you play on VMSwitch with the Hyper-V it will also impact over the docker J