Cowborg
Cowborg

Reputation: 2871

docker-compose portmapping gives failed to create endpoint hnsCall failed in Win32: The specified port already exists

I have started a new (.net core 3.0)project in Visual Studio, with Docker support (Windows)

I have added Docker support (right-click on project Add->Docker support) and in the same way added Docker compose support.

If I just Click "play-button" for Docker Compose, the project starts everything works well.

But when I run docker-compose up from the solution folder I get

Cannot start service testproj30: failed to create endpoint testproj30_testproj30_1 on network nat: hnsCall failed in Win32: The specified port already exists.

(I have closed my VS solution). If I remove the port mapping in docker-compose.override.yaml I dont get this error message. I have dont the most common tricks with restarting docker servce, hni service and so on. Nothing helps.

I dont want to depend on all VS-voodoo from the project file and God knows what other files that are involved.

I can run docker run -p 8080:80 443:443 without any port problems

Upvotes: 2

Views: 3464

Answers (1)

Karbos 538
Karbos 538

Reputation: 3055

I fixed a similar problem by removing some terminated container and then pruning networks.

List terminated container :

docker ps -a

Remove them (Cygwin syntax) :

docker rm $(docker ps -aq)

You will have error message for runnnig containers.

Clean your networks :

docker network prune

For myself, the main cause was the Docker killing process skiped the port releasing mechanism of my application.

Upvotes: 2

Related Questions