apache / apache/dubbo-website

docker swarm 集群环境 dubbo 注册 IP 默认为 docker_gwbridge IP 导致无法获取元数据

Open
#3,075 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
CSS
Stars
491
Forks
809
Avg merge
1d 6h
Merged PRs (30d)
6

Description

docker swarm 集群环境 Docker Engine Version 23.0.6
使用镜像 nacos-server:v2.3.2
Spring boot 应用 Maven 依赖
nacos-discovery-spring-boot-starter 0.3.0-RC
dubbo-spring-boot-starter 3.2.14

现在的问题是,容器应用在 nacos 注册中心注册的 dubbo 实例 IP 是读取的 docker_gwbridge IP (172.18.0.9) 而不是容器 overlay IP (10.0.1.18)
这样导致,位于不同宿主机上的容器 dubbo 服务注册,消费者获取不到提供者的元数据
原因是,docker_gwbridge IP 是基于宿主机分配的桥接网络地址(scope: local),不同的宿主机容器之间是不可以通过这个 IP 来互相访问
容器间的访问,是应该基于服务名(无法通过 dubbo.protocal.host 注册)或是 overlay IP (scope: swarm) 来访问的

网络是没有问题的,进入容器后 $(docker exec -it container-id)
容器之间通过 curl {overlay IP} 访问测试,是没有任何问题的
显而易见,只要将 容器的 overlay IP 注册到 nacos 中心,就应该能解决问题,但我不知道如何去进行控制。

在 docker swarm 中,采用 host 模式部署是可行的,但这样无法进行有效的容器 scale。
我需要的是,在容器进行 scale 时,通过 swam 集群动态分配给容器的 overlay ip 来解决容器间的 dubbo 服务调用。

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the problem in Docker Swarm using Docker Engine 23.0.6, nacos-server:v2.3.2, nacos-discovery-spring-boot-starter 0.3.0-RC, and dubbo-spring-boot-starter 3.2.14. Start by tracing how the container address registered in Nacos is selected; done means scaled services register their overlay IP and cross-host consumers can retrieve provider metadata.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, java, spring-boot
Domain
backend, distributed-systems, networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.