docker: driver failed programming external connectivity on endpoint webserver

Docker

Docker Problem Overview


I am trying to run a docker example following this documentation

This is my command:

docker run -d -p 80:80 --name webserver nginx

But I get this error:

> docker: Error response from daemon: driver failed programming external connectivity on endpoint webserver (bd57efb73c738e3b271db180ffbee0a56cae86c8193242fbc02ea805101df21e): Error starting userland proxy: Bind for 0.0.0.0:80: unexpected error (Failure EADDRINUSE).

How do I fix this?

Docker Solutions


Solution 1 - Docker

From your error message, the EADDRINUSE indicates port 80 is already in use on either the docker VM or possibly directly on your laptop. You can either stop whatever is running on that port, or change the port used in your Docker, command. To change to the external port 8080, use:

docker run -d -p 8080:80 --name webserver nginx

Solution 2 - Docker

If you are the port i not in use, try restarting docker. That usually works for me.

enter image description here

Solution 3 - Docker

I had the same issue with one of my containers. I tried everything but when nothing worked, I tried the following and launched the container again with success

 sudo service docker stop
 sudo rm /var/lib/docker/network/files/local-kv.db
 sudo service docker start

Solution 4 - Docker

Try restarting the docker service. It works 99% of the time.

service docker restart

If that didn't work as expected, try restarting your pc and then restarting the docker service using above command.

If none of the above worked try changing the exposed port to another unused port that should work.

docker run -d -p 81:80 --name webserver nginx

Note :- 81 is the port on your host and 80 is the port on your docker container

Solution 5 - Docker

For the first time, when i made a docker simple web app, i also faced same problem.

Simply you can try the following steps to resolve the problem and also able to understand the reason why you had faced the problem in details.

Step-1: check all the running containers using the command:

docker ps

Step-2: Find out the container id of the container which is running on the same port, you are trying to reach.

enter image description here

Step-3: Stop the container which one is running on the same port using this command:

docker stop <container id> 

Step-4: Again build the container:

docker build -t DockerID/projectName .

Step-5: Again try to run your container on the same port using port mapping.

docker run -p 8080:8080 DockerID/projectName

Solution 6 - Docker

Try this command:

sudo service docker restart

If it does not help, restart your server.

Solution 7 - Docker

Stop all the running containers docker ps -a -q then Stop the Docker on your machine & restart it.

Solution 8 - Docker

Recently this problem started to happen a lot on Windows. You can try restarting docker or you can manually stop docker before Windows shutdown - docker starts cleanly on reboot. On 7/24/2018 docker issue is open and further details can be found at https://github.com/docker/for-win/issues/1967

Solution 9 - Docker

Check what's on port 80 right now - sudo ss -tulpn | grep :80

You may have apache2 running. You can check it - sudo service apache2 status If so - sudo service apache2 statop

Solution 10 - Docker

In my case, port 80 is the default port for the web server and therefore it is protected. I changed the bind to port 60:8080 to ensure no deeper issues. Changing the bind to a different port allows me to execute the docker run and hit it in the browser at http://ip:60

Solution 11 - Docker

I had same problem with same error. As long as I had a local nginx installed in my computer, running another nginx through the container made conflict in port :80. Simply I tried to stop the service of my local installed nginx as below:

sudo service nginx stop

Then after, I could run nginx by docker-compose up -d without any problem:

Creating MyWebServer ... done
Creating mongo    ... done
Creating redis    ... done

Solution 12 - Docker

windows users: docker description

> On Windows systems, CTRL+C does not stop the container. So, first type > CTRL+C to get the prompt back (or open another shell), then type > docker container ls to list the running containers, followed by docker > container stop to stop the container. > Otherwise, you get an error response from the daemon when you try to > re-run the container in the next step.

I had the same problem, I thought with CTRL+C stoped the container but it was not the case, any af the answer above works because they all stop containers, restarting docker or stoping container explicity.

I prefer:

docker container ls #list containers running
docker stop [container id] #replace [container id] with the container id running

Solution 13 - Docker

This seems to be an incompatibility problem with windows "fast-boot" as described here: (just restart the docker service) and it may work.

https://github.com/docker/for-win/issues/2722

This is caused by an incompatibility with Docker and fastboot. You can either make sure you stop all containers before shutting Windows down or you can disable fastboot in Windows' power settings by doing the following:

CTRL+R > "powercfg.cpl" > "Choose what the power buttons do" > "Change settings that are currently unavailable" > Deselect "Turn on fast start-up"

You can also disable fastboot with a single command in powershell if you're comfortable doing so:

Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power\' -Name HiberbootEnabled -Value 0

Solution 14 - Docker

For me, a simple

ddev poweroff

fixed this.

Solution 15 - Docker

If this case is with Redis: remove the ports - ... in the docker-compose file and let it assign by itself. or change the port mapping in the host from 6379:6379 to 6378:6379 that worked for me.

Solution 16 - Docker

In my case what was blocking the port was a port forwarding rule for that port on one of my active VirtualBox guests. I removed the rule and docker stopped complaining.

Solution 17 - Docker

If you tried all above solutions and still having issues, you can kill LISTEN ports manually as below for Linux users

  1. sudo lsof -i -P -n | grep LISTEN enter image description here
  2. sudo kill -9 (ex. sudo kill -9 28563 28575 28719 28804)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIstiak MorsalinView Question on Stackoverflow
Solution 1 - DockerBMitchView Answer on Stackoverflow
Solution 2 - DockerLone RoninView Answer on Stackoverflow
Solution 3 - DockersmishraView Answer on Stackoverflow
Solution 4 - DockerCharith JayasankaView Answer on Stackoverflow
Solution 5 - DockerYeasin ArafathView Answer on Stackoverflow
Solution 6 - DockerJulius SimanavičiusView Answer on Stackoverflow
Solution 7 - DockerSomView Answer on Stackoverflow
Solution 8 - Dockersergeyski.comView Answer on Stackoverflow
Solution 9 - DockerDeveloperView Answer on Stackoverflow
Solution 10 - DockerlakewoodView Answer on Stackoverflow
Solution 11 - DockermabedisView Answer on Stackoverflow
Solution 12 - DockerJohn Balvin AriasView Answer on Stackoverflow
Solution 13 - Dockeratom88View Answer on Stackoverflow
Solution 14 - DockerjanischView Answer on Stackoverflow
Solution 15 - DockerAman KassahunView Answer on Stackoverflow
Solution 16 - DockerAspiring DevView Answer on Stackoverflow
Solution 17 - DockeribrahimkesiciView Answer on Stackoverflow