Docker Error bind: address already in use

こ雲淡風輕ζ 提交于 2019-11-28 17:02:26

问题


When I run docker-compose up in my Docker project it failes with the following message:

Error starting userland proxy: listen tcp 0.0.0.0:3000: bind: address already in use

netstat -pna | grep 3000 shows this:

tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN      -  

I've already tried docker-compose down, but it doesn't help.


回答1:


In your case it was some other process that was using the port and as indicated in the comments, sudo netstat -pna | grep 3000 helped you in solving the problem.

While in other cases (I myself encountered it many times) it mostly is the same container running at some other instance. In that case docker ps was very helpful as often I left the same containers running in other directories and then tried running again at other places, where same container names were used.

How docker ps helped me: docker rm -f $(docker ps -aq) is a short command which I use to remove all containers.

Edit: Added how docker ps helped me.




回答2:


This helped me:

docker-compose down
docker rm -fv $(docker ps -aq)
sudo lsof -i -P -n | grep <port number>

and then: kill -9 <process id> (macOS) or sudo kill <process id> (Linux).

Source: comment by user Rub21.




回答3:


I had the same problem. I fixed this by stopping the Apache2 service on my host.




回答4:


I had same problem,
docker-compose down --rmi all (in the same directory where you run docker-compose up)
helps




回答5:


In my case it was

Error starting userland proxy: listen tcp 0.0.0.0:9000: bind: address already in use

And all that I need is turn off debug listening in php storm




回答6:


I ran into the same issue several times. Restarting docker seems to do the trick




回答7:


I upgraded my docker this afternoon and ran into the same problem. I tried restarting docker but no luck.

Finally, I had to restart my computer and it worked. Definitely a bug.




回答8:


I resolve the issue by restarting Docker.




回答9:


docker-compose down --rmi all 

and then restart your computer




回答10:


For Linux/Unix:

Simple search for linux utility using following command

netstat -nlp | grep 8888

It'll show processing running at this port, then kill that process using PID (look for a PID in row) of that process.

kill PID


来源:https://stackoverflow.com/questions/37971961/docker-error-bind-address-already-in-use

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!