docker: driver failed programming external connectivity on endpoint webserver
DockerDocker 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
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.
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
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.