简体   繁体   中英

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

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

This solution helped me:

net stop winnat
docker start container_name
net start winnat

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.

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

Restarting winnat is not a good idea, the root cause is that some ports of windows are dynamically reserved, even though they are not occupied.This command can be used to solve.

netsh int ipv4 set dynamic tcp start=49152 num=16384
netsh int ipv6 set dynamic tcp start=49152 num=16384

This article explains it in detail, and I recommend taking a look at it.

Completely solve the problem of docker containers running on Windows 10 due to port binding

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

I faced with this situation when my VPN connection is active.
you can temporarily disconnect your VPN connection, after that start your docker container , and go back and connect to your VPN again

  1. run net stop winnat
  2. If you use docker desktop, just run the container. Otherwise run this command in command prompt: docker start <container_name>
  3. run net start winnat

Try restarting "Host Network Service"

This is often caused by the Windows NAT Driver (winnat), stopping and restarting that service may resolve the issue.

open shell as administrator, and types those commands:

  1. net stop winnat.
  2. docker start...
  3. net start winnat
***net stop winnat
docker start container_name
net start winnat***

writing this in cmd worked well for me, thank you so much commentators for the solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM