Closed georgeaniljohn closed 5 years ago
@Cardds can you assist w/ this please?
@georgeaniljohn Can the stack file be posted, with associated network information & related configuration?
@Cardds The network is being created by running the script:
docker network create --driver=overlay sample-net
docker-compose file for the stack:
version: "3.5"
networks: sample-net: external: true
services: mongodb1: hostname: mongodb1 image: "sample-registry:5000/mongodb:latest" deploy: restart_policy: condition: on-failure ports:
"27017:27017" volumes:
mongodb2: hostname: mongodb2 image: "sample-registry:5000/mongodb:latest" deploy: restart_policy: condition: on-failure ports:
mongodb3: hostname: mongodb3 image: "sample-registry:5000/mongodb:latest" deploy: restart_policy: condition: on-failure ports:
"29019:27017" volumes:
sample-node: hostname: sample-node image: "sample-registry:5000/node:latest" deploy: mode: replicated replicas: 2 restart_policy: condition: on-failure endpoint_mode: dnsrr depends_on:
@georgeaniljohn The file posted does not appear to have any reference to specifying the endpoint_mode
as dnsrr
. See https://docs.docker.com/compose/compose-file/#endpoint_mode for associated docker compose documentation; note there it was only introduced in stack files as of verison 3.3.
@Cardds sorry that it was missed out when posting initially and I updated it now. The issue got resolved now after specifying the entire service name along with stack name. eg: -DserviceName=stack-name_sample-node. But thank you for reaching out .
Seems the hazelcast is not forming a cluster when service deployed in a docker stack using method DNSRR with the help of a docker-compose file. Each node now acts as an individual master.
But working perfectly fine when service deployed outside stack as
docker service create --network sample-net --name sample-node --endpoint-mode dnsrr --restart-condition on-failure --constraint 'node.hostname !=sample-machine-3' --replicas 2 -e "SPRING_DATA_MONGODB_URI=mongodb://10.10.30.31:27017,10.10.30.32:27017,10.10.30.33:27017/sampledb" -e "HZ_MANCENTER_URI=http://10.10.30.33:8080/mancenter" -e "HZ_GROUP=live-sample" -e "JAVA_OPTS=-DserviceName=sample-node -DservicePort=6781 -DpeerServicesCsv=sample-node:6781" sample-registry:5000/sampleimage:latest