version: "3.4" networks: #******************************************# replica_set1_network: driver: bridge ipam: config: - subnet: 168.20.1.0/24 #******************************************# replica_set2_network: driver: bridge ipam: config: - subnet: 168.20.2.0/24 #******************************************# replica_set3_network: driver: bridge ipam: config: - subnet: 168.20.3.0/24 #******************************************# services: primary1: hostname: primary1 image: mongo:latest ports: - "10001:27017" command: ["mongod", "--replSet", "rep-set1"] networks: replica_set1_network: #************** secondary1_1: hostname: secondary1_1 image: mongo:latest ports: - "10002:27017" command: ["mongod", "--replSet", "rep-set1"] networks: replica_set1_network: #************** secondary1_2: hostname: secondary1_2 image: mongo:latest ports: - "10003:27017" command: ["mongod", "--replSet", "rep-set1"] networks: replica_set1_network: #************************************************************* primary2: hostname: primary2 image: mongo:latest ports: - "20001:27017" command: ["mongod", "--replSet", "rep-set2"] networks: replica_set2_network: #************** secondary2_1: hostname: secondary2_1 image: mongo:latest ports: - "20002:27017" command: ["mongod", "--replSet", "rep-set2"] networks: replica_set2_network: #************** secondary2_2: hostname: secondary2_2 image: mongo:latest ports: - "20003:27017" command: ["mongod", "--replSet", "rep-set2"] networks: replica_set2_network: #************************************************************* primary3: hostname: primary3 image: mongo:latest ports: - "30001:27017" command: ["mongod", "--replSet", "rep-set3"] networks: replica_set3_network: #************** secondary3_1: hostname: secondary3_1 image: mongo:latest ports: - "30002:27017" command: ["mongod", "--replSet", "rep-set3"] networks: replica_set3_network: #************** secondary3_2: hostname: secondary3_2 image: mongo:latest ports: - "30003:27017" command: ["mongod", "--replSet", "rep-set3"] networks: replica_set3_network: #*************************************************************