Docker错误绑定:地址已在使用中 [英] Docker Error bind: address already in use
问题描述
当我在Docker项目中运行docker-compose up
时,它失败并显示以下消息:
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
显示如下:
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN -
我已经尝试过docker-compose down
,但这无济于事.
I've already tried docker-compose down
, but it doesn't help.
推荐答案
在您的情况下,使用端口的是其他进程,如注释中所示,sudo netstat -pna | grep 3000
帮助您解决了问题.
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.
虽然在其他情况下(我本人也曾多次遇到过),但大多数情况下,它是在其他情况下运行的同一容器.在那种情况下,docker ps
很有帮助,因为通常我将相同的容器留在其他目录中运行,然后尝试在其他使用相同容器名称的地方再次运行.
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.
docker ps
如何帮助我: docker rm -f $(docker ps -aq)
是用于删除所有容器的简短命令.
How docker ps
helped me: docker rm -f $(docker ps -aq)
is a short command which I use to remove all containers.
编辑:添加了docker ps
如何帮助我.
Added how docker ps
helped me.
这篇关于Docker错误绑定:地址已在使用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!