Reputation: 511
I'm trying to run the following docker command (latest Win10 Fall 2018 update, latest docker version 2.0):
docker run -d -p 1433:1433 -e sa_password=Test_123 -e ACCEPT_EULA=Y microsoft/mssql-server-windows-developer
But it fails wit the following error:
Error response from daemon: failed to create endpoint unruffled_wozniak on network nat: hnsCall failed in Win32: The process cannot access the file because it is being used by another process. (0x20).
I've tried the following:
docker system prune -a
Nothing worked. Any suggestions?
Upvotes: 42
Views: 51543
Reputation: 1
This is simple one solved at my end. when we run docker we need to always stop iis through command line just stop IIS its working for me
run docker compose up command it will work
Upvotes: 0
Reputation: 11
Setting the Windows system dynamic port range can be solved
netsh int ipv4 set dynamicport tcp start=35001 num=30535
Upvotes: 1
Reputation: 193
In my case, the issue was that the port that I was trying to bind to (50055) was being reserved by the OS.
To view Windows' reserved port ranges:
netsh interface ipv4 show excludedportrange protocol=tcp
Protocol tcp Port Exclusion Ranges
Start Port End Port
---------- --------
5357 5357
49677 49776
49877 49976
50000 50059 *
50160 50259
50360 50459
50564 50663
50664 50763
* - Administered port exclusions.
I removed the offending port range by running (as admin):
netsh int ipv4 delete excludedportrange protocol=tcp startport=50000 numberofports=60
Though this worked for me, removing these reservations isn't always this straight forward.
See this SO question for more details.
Also relevant: https://github.com/docker/for-win/issues/3171
Upvotes: 4
Reputation: 695
Seems like there's a difference between Linux's and Windows' error messages.
Command:
docker run -d -p 80:80 my_image
Linux's error message:
docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:80: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
Windows' error message:
docker: Error response from daemon: failed to create endpoint admiring_matsumoto on network nat: failed during hnsCallRawResponse: hnsCall failed in Win32: The process cannot access the file because it is being used by another process. (0x20).
After changing the command to
docker run -d -p 81:80
Worked on both.
Then, I was able to see that, in my case there was a Windows Defender crashed service (that should be stopped) 'holding' port 80 and I could use port 80 again.
Upvotes: 2
Reputation: 208
On windows check ports Listener: PS:> Get-NetTCPConnection | findstr 1433
find process with ID = 12240 and kill them (com.docker.backend)
after my new port redirect work well!!!
Upvotes: 6
Reputation: 51
This occurs in windows if you are in docker with linux containers and there is a pending container which uses the port in windows containers. Try switching the containers to different os and stopping the container process. This worked for me.
Upvotes: 5
Reputation: 6541
Not sure how wise this is, but I checked the port wasn't in use with another app and still got the error.
This has fixed the issue a couple of times for me. In an Administrative PowerShell console, run the following:
Stop-Service docker
Stop-service hns
Start-service hns
Start-Service docker
docker network prune
Partially sourced from this post.
Upvotes: 52
Reputation: 301
I was running into the same error, but stopping the SQL Server service running on my local machine on port 1433 wasn't an option, so I simply mapped a different port to the container. I replaced the port mapping parameters with the following:
-p 1434:1433
This will map your local machine's port 1434 to the container's port 1433. If your local machine's port 1434 is also in use, you'll have to find a port that is available for you.
Once you have that in place, if you want to get in with SSMS, you'll just need to tell it to connect over port 1434 by using a comma:localhost,1434
Upvotes: 10
Reputation: 2908
I had the same issue while trying to get PostgreSQL running with Docker. The problem was that the port was already tied up! This was because I had already had PostgreSQL running as a normal database in my OS.
My fix was finding the postgresql-x64-10
service in the Task Manager (under Services) and stopping the service.
the solution probably sounds obvious but I thought I'd mention it anyway
Upvotes: 25