事情的起因是使用Dify或者RAGFlow的时候,需要使用docker启动,但是电脑使用docker启动后显示成功却不可以访问localhost:80或者其他端口。
网上有很多方法,列出如下(都没有解决):
1、将docker内的bridge换为host
没有尝试,因为这会将容器内的端口和主机端口直接重合,显然不是一个明智的选择。
2、升级linux内核
网上的docker安装分为linux和windows上,而docker安装前一般要安装wsl,所有有一种解决方法是升级linux内核(但是实际上这种方法应该只对linux系统有用,因为windows可以直接安装docker会默认安装符合版本的wsl2):
yum update -y
3、防火墙设置
将防火墙中对使用的端口进行全部通行。其实可以直接尝试将防火墙全部关闭,如果仍然没有用,显然不是由防火墙造成的。
4、Docker没有做端口映射
有些简单的镜像是没有做端口映射的,使用docker ps 查看一下即可
以上方法尝试的时候,还对各种防火墙、软件权限等进行了设置,全部都没有作用。
我的解决方法:
使用一个简单的镜像测试,发现容器内可以正常运行,但是访问不了网页。
我使用的Docker Desktop,然后直接关闭wsl2集成,切换到传统的hyper-v模式:
将这里取消后,直接报错:
The Privileged helper service is not running. The service runs in the background with SYSTEM privileges. Docker Desktop needs the service to interact with privileged parts of Windows. To learn more about the privileged helper service and the functions it provides, visit the docs. Would you like to start the service? Windows will ask you for elevated access.
这说明什么,说明有一个后台运行的 Privileged Helper Service(特权帮助服务)没有开启,所以所有的端口映射功能全部没有实现。
开启后就可以正常使用啦~~~~~~~~