我正在尝试通过多播将不同的Wildfly彼此连接。如果我在计算机上本地运行Wildfly,则它们会通过226.0.1.1相互对话
但是在docker中,网络中没有通信。
我当前的撰写文件如下:
version: '3.5'
services:
wildfly1:
build: ./wildfly_image
image: wildfly:latest
environment:
- WILDFLYNAME=wildfly1
networks:
wildfly_network:
wildfly2:
build: ./wildfly_image
image: wildfly:latest
environment:
- WILDFLYNAME=wildfly2
networks:
wildfly_network:
networks:
wildfly_network:
ipam:
driver: default
如果我运行docker network inspect <wildfly_network>
,则会得到以下结果:
[
{
"Name": "wildfly_network",
"Id": "fb6971c11fc46c9489ea09a32da8d775818aa60fe4a9ce70ef6622455b9d9f26",
"Created": "2019-04-11T12:23:12.177429621Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.18.0.0/16",
"Gateway": "172.18.0.1"
}
]
},
"Internal": false,
"Attachable": true,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"31edc263ca9e6114dac70cc1347093159eb64028730459ae316ffe941dae9c57": {
"Name": "wildfly2_1",
"EndpointID": "f26daa7b38bcaf40db337e29c3fe501a48b415d14def30b3ed943d9d309cbbf8",
"MacAddress": "02:42:ac:12:00:04",
"IPv4Address": "172.18.0.4/16",
"IPv6Address": ""
},
"32e30b11d07e1c30b9a885493e8614d0e809f537f99c46c6386492aa4a0a010a": {
"Name": "wildfly1_1",
"EndpointID": "7e79bcfacd28eb5a90734f21063655430e4a795391dbd4859b21d337b23c684a",
"MacAddress": "02:42:ac:12:00:05",
"IPv4Address": "172.18.0.5/16",
"IPv6Address": ""
},
},
"Options": {},
"Labels": {
"com.docker.compose.network": "wildfly_network",
"com.docker.compose.project": "docker",
"com.docker.compose.version": "1.23.2"
}
}
]
有人看到我的问题了吗?
谢谢
答案 0 :(得分:0)
我使用以下命令解决了这个问题:
ENTRYPOINT /opt/jboss/wildfly/bin/standalone.sh -b=0.0.0.0 -bmanagement=0.0.0.0 -Djboss.server.default.config=standalone-full-ha.xml -Djboss.node.name=${WILDFLY_NAME} -Djava.net.preferIPv4Stack=true -Djgroups.bind_addr=$(hostname -i) -Djboss.messaging.cluster.password=${CLUSTER_PW}
您必须将jgroup地址绑定到容器的本地地址,更改集群pw并使用ipv4
我还更新了GitHub存储库以显示当前正在运行的集群
答案 1 :(得分:-2)
如果网络的唯一目的是使您的服务可访问,请尝试直接在docker内直接访问服务,例如http://wildfly1,http://wildfly2。 Docker compose应该将两个服务都添加到默认网络中,并随服务名称一起提供给compose中的其他服务。有关更多信息,请参见docker doc
version: '3.5'
services:
wildfly1:
build: ./wildfly_image
image: wildfly:latest
environment:
- WILDFLYNAME=wildfly1
wildfly2:
build: ./wildfly_image
image: wildfly:latest
environment:
- WILDFLYNAME=wildfly2