We have the legacy application containerized and now we are trying to establish our CI/CD pipeline to have it deployed to our Dev cluster. Obviously, we will need the docker daemons running on all the host VMs. but we have a problem.

HNS failed with error : {Object Exists} An attempt was made to create an object and the object name already exists

Umm, what is going on?

Let's try

  Get-ContainerNetwork

Nothing returned.

Well, how about

   dockerd -D

Looks like the call to window OS network api failed.

A few google on the similar issues this moby issue 27984 provide the solution for me.

   mofcomp C:\Windows\System32\wbem\NetNat.mof 

wait a second, it doesn't work for my VM

let's try this

Stop-Service hns
del C:\ProgramData\Microsoft\Windows\HNS\HNS.data
Start-Service hns

Now, the docker daemon should be able to start.

However, It may not be the case; then you may have to clean up the container network

  • Remove Switch registry keys on the host (HKLM:\SYSTEM\CurrentControlSet\Services\vmsmp\parameters\SwitchList)
  • Remove NIC registry keys on the host (HKLM:\SYSTEM\CurrentControlSet\Services\vmsmp\parameters\NicList)
  • Unbind ALL physical network adapters (Get-NetAdapter) from ANY Hyper-V Virtual Switch components to which they are attached (Disable-NetAdapterBinding -Name -ComponentID vms_pp)
  • remove the HNS.data file (C:\ProgramData\Microsoft\Windows\HNS\HNS.data)