Can't run docker on windows 10 - Ports are not available

Viewed 7079

I'm trying to run a docker image on my windows 10 pro workstation and I'm getting this error:

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.

I'm running this command:

docker run -d -p 80:80 docker/getting-started

And getting this response back:

Unable to find image 'docker/getting-started:latest' locally
latest: Pulling from docker/getting-started
188c0c94c7c5: Pull complete
617561f33ec6: Pull complete
7d856acdaa9c: Pull complete
a0d3c6e28e6d: Pull complete
af69a9b963c8: Pull complete
0739f3815ad8: Pull complete
7c7b75d0baf8: Pull complete
Digest: sha256:b821569034e3b5fae03b40e64a866017067f3bf17effe185b782bdbf02179528
Status: Downloaded newer image for docker/getting-started:latest
7907f6de2b55cc2d66b5ed3a642ac1a97e5bb5ecda5fcf76ff60d7236e8fd32d
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.

I've tried completely uninstalling McAfee AntiVirus and turned off the local windows firewall.

I have protection at the router level, but I'm not sure that's causing the issue, and I would rather not disable that because it affects my whole home network.

How can I run docker and get past this problem?

6 Answers

Check if somthing is listening on port 80 by running PowerShell command:

Get-Process -Id (Get-NetTCPConnection -LocalPort 80).OwningProcess

If the response is something like this:

 NPM(K)    PM(M)      WS(M)     CPU(s)      Id  SI ProcessName
------    -----      -----     ------      --  -- -----------
0     0.20       4.87       0.00       4   0 System 

Then the it is taken. terminate the process or simply change the port

docker run -d -p 81:81 docker/getting-started 5a0b1202f48ef63c06d75c2f26be2a05f29aa84fe2fbdc5b66f989aa86df98f

When I encountered this error there was nothing actively listening on the port.However, the following command showed the port had been reserved by something else

netsh interface ipv4 show excludedportrange protocol=tcp

See This article for more details. A reboot fixed the issue for me.

Most times, Windows IIS (Internet Information Service) or some other program may be using port 80, which is the default http port used by Laravel, Apache and other PHP development environments. To resolve this issue, Open a new PowerShell window as administrator and simply run this command:

net stop http

A prompt listing all services using the http port is shown and you are given the option of stopping them. enter 'Y' and press Enter. All the services are stopped and port 80 is now free for whatever you want to use it for.

Very useful for testing multiple application environments locally on Windows without having to worry about port configuration.

in my case,the task manager show that a system process is occupy port 80.

when i dive deeper, i found a svchost.exe related to port 80, and it is based on world wide web service

so,just open service list and stop the world wide web service,then everything will be ok,the name of service maybe different, but should include keywords :world wide web

just do it

netsh http add iplisten ipaddress=::

(This has to be run in a command prompt with elevated rights!)

Related