Fixing “HNS failed with error : Unspecified error” on docker-compose for Windows
This post was originally published on Marcel de Vries' blog at Fixing “HNS failed with error : Unspecified error” on docker-compose for Windows.
The past few days I worked quite a lot with docker-compose on my windows machine and after something strange happened to my machine that crashed it, I was not able to start any containers anymore that had connectivity over the network with each other.
Every time I used the command-line docker-compose up, I would get a message telling me it failed to start the container. the full message I got was:
“ERROR: for web Cannot start service web: failed to create endpoint aspnetblogapplication_web_1 on network nat: HNS failed with error : Unspecified error”
Some searches on the internet gave me options where I needed to reset some of my network configuration using PowerShell. Most of these posts refer to Technical Preview 5 of Windows Server 2016, but I am now running these containers on windows 10 anniversary edition.
The way to solve the issue was rather simple, but overlooked by most people it seems. And it is not mentioned anywhere as the solution to this problem.
If you go to the tray icon and open the tool, there is an option called Reset
If you select to the factory defaults, it will also reset the things that cause the problem and your Docker tools work again. I must say I have no clue what caused the problem, but this was the only solution that works like a charm.
Only nasty side effect is that it also resets all your local images, so all images you pulled or build on your local machine will be removed and need to be fetched again or rebuild.