generated from anteqkois/template-typescript-simple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-compose.replica.yml
72 lines (69 loc) · 1.58 KB
/
docker-compose.replica.yml
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
version: "3"
services:
mongodb:
image: mongo:4.2.8-bionic
volumes:
- ./raw_db:/data/db
- ./mongo:/etc/mongo
ports:
- 27017:27017
expose:
- 27017
restart: unless-stopped
command: ["--config", "/etc/mongo/mongod.conf"]
mongodb2:
image: mongo:4.2.8-bionic
volumes:
- ./raw_db_2:/data/db
- ./mongo:/etc/mongo
ports:
- 27018:27017
expose:
- 27018
command: ["--config", "/etc/mongo/mongod.conf"]
restart: unless-stopped
# mongodb3:
# image: mongo:4.2.8-bionic
# volumes:
# - ./raw_db_3:/data/db
# - ./mongo:/etc/mongo
# ports:
# - 27019:27017
# command: ["--config", "/etc/mongo/mongod.conf"]
# restart: unless-stopped
# # container to initialize replica set
# mongoinit:
# image: mongo:4.2.8-bionic
# # this container will exit after executing the command
# restart: "no"
# depends_on:
# - mongodb
# - mongodb2
# - mongodb3
# command: >
# sleep 5 &&
# mongo --host mongodb:27017 -u ${DB_ADMIN} -p ${DB_ADMIN_PASS} --authenticationDatabase admin --eval
# '
# config = {
# "_id" : "rsMain",
# "members" : [
# {
# "_id" : 0,
# "host" : "mongodb:27017"
# },
# {
# "_id" : 1,
# "host" : "mongodb2:27017"
# },
# {
# "_id" : 2,
# "host" : "mongodb3:27017"
# }
# ]
# };
# rs.initiate(config);
# '
# && echo "Replica set initialized"
networks:
default:
name: network_name