I am trying to run a docker example following this documentation
This is my command:
docker run -d -p 80:80 --name webserver nginx
<
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
Try this command:
sudo service docker restart
If it does not help, restart your server.
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
Stop all the running containers docker ps -a -q
then
Stop the Docker on your machine & restart it.
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
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