docker: driver failed programming external connectivity on endpoint webserver
Solution 1:
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:
If you are the port i not in use, try restarting docker. That usually works for me.
Solution 3:
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:
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:
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