-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Is there an existing issue for this?
- I have searched the existing issues
Current Behavior
在阅读了官方README的快速上手部署容器后,我在 macOS 宿主机上启动了一个监听 127.0.0.1:8080 的 HelloWorld 后端服务,并严格按照指南启动 shenyu-admin 和 shenyu-bootstrap 容器(均在 shenyu Docker 网络中)并配置了selectorHandler,当尝试通过网关(http://localhost:9195/helloworld)访问后端服务时,shenyu-bootstrap 容器日志显示它尝试连接自身内部的 127.0.0.1:8080,而不是宿主机上运行的后端服务。这直接导致了 Connection refused 错误❌
Expected Behavior
原因是我启动的后端HelloWorld服务在宿主机上,容器内部访问127.0.0.1无法映射到宿主机
仔细阅读了文档后,可能的意思是
- 后端服务被打包并运行在了 shenyu-bootstrap 容器的内部,并且监听了这个容器自己的 127.0.0.1 (localhost) 的 8080 端口(不太可能)
- 在docker shenyu network中,用户需要自己部署一个后端服务, 但文档本身并没有提供启动这个示例后端服务的步骤
🤯新手困惑的原因:
在 Docker 环境下,shenyu-bootstrap 容器内的 127.0.0.1:8080 指向的是该容器自身
对于Docker 网络上下文不太熟悉的用户(以前的我),可能期望快速上手提供一个无需修改就能直接工作的端到端示例,容易将 127.0.0.1:8080 理解为宿主机的 localhost
💡可能的解决方案:
- 引导用户在宿主机上启动后端服务并监听localhost:8080, 同时把upstreamUrl改为host.docker.internal:8080
- 提供在docker shenyu network中启动后端示例服务的步骤
Steps To Reproduce
按照快速上手(docker)部署shenyu并配置selectorHandler upstreamUrl为127.0.0.1:8080, 同时在宿主机启动后端服务
Environment
ShenYu version(s):docker latest
运行环境:macOS (Docker Desktop)Debug logs
[0a883217-38] formatError:Resolved [AnnotatedConnectException: finishConnect(..) failed: Connection refused: /127.0.0.1:8080] for HTTP GET /favicon.ico throwable:
io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: /127.0.0.1:8080
Anything else?
No response