15
votes

I am trying to start a docker container with the below command.

docker run -it -p 50070:50070 -p 8088:8088 -p 8080:8080 suhothayan/hadoop-spark-pig-hive:2.9.2 bash

It ended up with the following error.

docker: error response from daemon: Ports are not available: listen tcp 0.0.0.0/50070: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

As I understand, the error has occurred as the port 50070 is used by another process. I've tried to identify the process in order to kill that with the below command in the command prompt, but it does not give an output nor an error.

netstat -ano | findstr :50080
4

4 Answers

16
votes

As per Docker issue for windows https://github.com/docker/for-win/issues/3171 :

You might have that port in any of the excluded port ranges of command netsh interface ipv4 show excludedportrange protocol=tcp

You can use solution mentioned in the above ticket.

  1. Disable hyper-v (which will required a couple of restarts)

    dism.exe /Online /Disable-Feature:Microsoft-Hyper-V

  2. After finishing all the required restarts, reserve the port you want so hyper-v doesn't reserve it back

    netsh int ipv4 add excludedportrange protocol=tcp startport=50070 numberofports=1

  3. Re-Enable hyper-V (which will require a couple of restart)

    dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

59
votes

This solution helped me:

net stop winnat
docker start ...
net start winnat
3
votes

I did this to stop tcp processes =>

  • net stop winnat
  • net start winnat

In this way, the busy port operation is terminated.

This worked for me.

0
votes

On my local machine had similar issue with Docker Desktop and integration enabled with Debian/Ubuntu set as default distro (WSL2 as standard to all). How I solved:

  • Docker settings disabled "Start Docker Desktop when you log in"
  • Restarting Windows
  • First starting Debian/Ubuntu
  • Then start Docker Desktop