当我在Docker项目中运行Docker -compose up时,它失败了,并显示以下消息:
启动userland代理时错误:监听tcp 0.0.0.0:3000:绑定:地址已在使用
netstat -pna | grep 3000
显示了这个:
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN -
我已经试过docker-compose down了,但没用。
当我在Docker项目中运行Docker -compose up时,它失败了,并显示以下消息:
启动userland代理时错误:监听tcp 0.0.0.0:3000:绑定:地址已在使用
netstat -pna | grep 3000
显示了这个:
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN -
我已经试过docker-compose down了,但没用。
当前回答
你可以用下面的命令杀死监听该端口的进程:
kill -9 $(lsof -t -i tcp:<port#>)
ex :
(lsof -t -i tcp:<port#>)
或者ubuntu:
Sudo lsof -t -i:8000 '
lsof的手册页:https://man7.org/linux/man-pages/man8/lsof.8.html
-9是硬杀,不检查任何deps。
(不相关,但可能有用,如果它的PORT 5000神秘)-罪魁祸首进程是由于Mac OS monterery。
端口5000通常用于为本地开发服务器提供服务。当更新到最新的macOS操作系统时,我无法将docker绑定到端口5000,因为它已经在使用中。(您可能会发现一条类似Port 5000已被使用的消息。)
通过运行lsof -i:5000,我发现使用端口的进程名为ControlCenter,这是一个原生macOS应用程序。如果这种情况发生在您身上,即使您使用暴力(并杀死)应用程序,它也会重新启动。在我的笔记本电脑中,lsof -i:5000返回控制中心正在被id为433的进程使用。我可以杀死所有-p 433,但macOS不断重新启动进程。
在这个端口上运行的进程原来是一个AirPlay服务器。你可以在
系统首选项›共享,取消检查AirPlay接收器以释放端口5000。
其他回答
这帮助了我:
docker-compose down # Stop container on current dir if there is a docker-compose.yml
docker rm -fv $(docker ps -aq) # Remove all containers
sudo lsof -i -P -n | grep <port number> # List who's using the port
然后: kill -9 <进程id> (macOS)或sudo kill <进程id> (Linux)。
来源:用户Rub21的评论。
我已经用另一个端口运行了集装箱,比如……8082: -)
使用8888端口的是Jupiter,我必须更改Jupiter笔记本的配置文件以在另一个端口上运行。
列出谁在使用该特定端口。 9 . sudo lsof -i -P -n | grep
你可以在~/.jupyter/jupyter_notebook_config.py中指定你想要Jupyter运行的端口,不注释/编辑下面的行:
c.NotebookApp.port = 9999
如果你没有jupyter_notebook_config.py,试着运行jupyter notebook——generate-config。有关Jupyter配置的更多详细信息,请参见此。
我试了所有的方法,包括关闭播放功能,但都没有效果。
最后,这个简单的解决方案奏效了。 在应用程序运行定义主机为0.0.0.0和端口5000显式,并bing一切工作
app.run(debug=True,host="0.0.0.0",port=5000)
现在运行应用程序为
docker run -p 5000:5000 <Image Name>
@DmitrySandalov的回答:我在8080上运行tomcat/java,它需要继续运行。看看船坞。Yml文件并将8080的条目更改为我选择的另一个条目。
nginx:
build: nginx
ports:
#- '8080:80' <-- original entry
- '8880:80'
- '8443:443'
完美的工作。(唯一的问题是,如果我更新项目,更改将被删除,因为它来自外部回购。)