-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmongodb-cluster.yaml
38 lines (34 loc) · 1022 Bytes
/
mongodb-cluster.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
version: "3.8"
services:
mongo1:
image: mongo:4.2
container_name: mongo1
command: ["--replSet", "my-replica-set", "--bind_ip_all", "--port", "40000"]
volumes:
- ./data/mongo-1:/data/db
ports:
- 40000:40000
healthcheck:
test: test $$(echo "rs.initiate({_id:'my-replica-set',members:[{_id:0,host:\"mongo1:40000\"},{_id:1,host:\"mongo2:40001\"},{_id:2,host:\"mongo3:40002\"}]}).ok || rs.status().ok" | mongo --port 40000 --quiet) -eq 1
interval: 10s
start_period: 30s
mongo2:
image: mongo:4.2
container_name: mongo2
command: ["--replSet", "my-replica-set", "--bind_ip_all", "--port", "40001"]
volumes:
- ./data/mongo-2:/data/db
ports:
- 40001:40001
mongo3:
image: mongo:4.2
container_name: mongo3
command: ["--replSet", "my-replica-set", "--bind_ip_all", "--port", "40002"]
volumes:
- ./data/mongo-3:/data/db
ports:
- 40002:40002
networks:
default:
name: local-environment
external: true