-
Notifications
You must be signed in to change notification settings - Fork 0
/
mongodb-replica.yml
97 lines (96 loc) · 3.82 KB
/
mongodb-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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# https://hub.docker.com/r/bitnami/mysql
services:
mongodb-primary:
image: ${MONGODB_IMAGE}
container_name: mongodb-primary
privileged: true
restart: on-failure
environment:
- TZ=Asia/Shanghai
- MONGODB_REPLICA_SET_MODE=primary
- MONGODB_REPLICA_SET_KEY=${MONGODB_REPLICA_SET_KEY}
- MONGODB_ADVERTISED_HOSTNAME=${MONGODB_REPLICA_PRIMARY_ADVERTISED_HOSTNAME}
- ALLOW_EMPTY_PASSWORD=${MONGODB_ALLOW_EMPTY_PASSWORD}
- MONGODB_USERNAME=${MONGODB_USERNAME}
- MONGODB_PASSWORD=${MONGODB_PASSWORD}
- MONGODB_DATABASE=${MONGODB_DATABASE}
- MONGODB_ROOT_PASSWORD=${MONGODB_ROOT_PASSWORD}
- MONGODB_EXTRA_FLAGS=${MONGODB_EXTRA_FLAGS}
- MONGODB_ENABLE_JOURNAL=${MONGODB_ENABLE_JOURNAL}
- MONGODB_ENABLE_NUMACTL=${MONGODB_ENABLE_NUMACTL}
- MONGODB_ENABLE_DIRECTORY_PER_DB=${MONGODB_ENABLE_DIRECTORY_PER_DB}
volumes:
- ${MONGODB_REPLICA_PRIMARY_HOME}/primary:/bitnami/mongodb
networks:
- mongodb_replica
ports:
- ${MONGODB_REPLICA_PRIMARY_PORT_27017}:27017
healthcheck:
test: mongosh --eval 'db.runCommand("ping").ok' --quiet
mongodb-secondary:
image: ${MONGODB_IMAGE}
container_name: mongodb-secondary
privileged: true
restart: on-failure
environment:
- TZ=Asia/Shanghai
- MONGODB_REPLICA_SET_MODE=secondary
- MONGODB_REPLICA_SET_KEY=${MONGODB_REPLICA_SET_KEY}
- MONGODB_ADVERTISED_HOSTNAME=${MONGODB_REPLICA_SECONDARY_ADVERTISED_HOSTNAME}
- MONGODB_INITIAL_PRIMARY_HOST=${MONGODB_REPLICA_PRIMARY_ADVERTISED_HOSTNAME}
- MONGODB_INITIAL_PRIMARY_PORT_NUMBER=27017
- MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD=${MONGODB_ROOT_PASSWORD}
- ALLOW_EMPTY_PASSWORD=${MONGODB_ALLOW_EMPTY_PASSWORD}
- MONGODB_USERNAME=${MONGODB_USERNAME}
- MONGODB_PASSWORD=${MONGODB_PASSWORD}
- MONGODB_DATABASE=${MONGODB_DATABASE}
- MONGODB_ROOT_PASSWORD=${MONGODB_ROOT_PASSWORD}
- MONGODB_EXTRA_FLAGS=${MONGODB_EXTRA_FLAGS}
- MONGODB_ENABLE_JOURNAL=${MONGODB_ENABLE_JOURNAL}
- MONGODB_ENABLE_NUMACTL=${MONGODB_ENABLE_NUMACTL}
- MONGODB_ENABLE_DIRECTORY_PER_DB=${MONGODB_ENABLE_DIRECTORY_PER_DB}
volumes:
- ${MONGODB_REPLICA_SECONDARY_HOME}/secondary:/bitnami/mongodb
networks:
- mongodb_replica
depends_on:
- mongodb-primary
ports:
- ${MONGODB_REPLICA_SECONDARY_PORT_27017}:27017
healthcheck:
test: mongosh --eval 'db.runCommand("ping").ok' --quiet
mongodb-arbiter:
image: ${MONGODB_IMAGE}
container_name: mongodb-arbiter
privileged: true
restart: on-failure
environment:
- TZ=Asia/Shanghai
- MONGODB_REPLICA_SET_MODE=arbiter
- MONGODB_REPLICA_SET_KEY=${MONGODB_REPLICA_SET_KEY}
- MONGODB_ADVERTISED_HOSTNAME=${MONGODB_REPLICA_ARBITER_ADVERTISED_HOSTNAME}
- MONGODB_INITIAL_PRIMARY_HOST=${MONGODB_REPLICA_PRIMARY_ADVERTISED_HOSTNAME}
- MONGODB_INITIAL_PRIMARY_PORT_NUMBER=27017
- MONGODB_INITIAL_PRIMARY_ROOT_PASSWORD=${MONGODB_ROOT_PASSWORD}
- ALLOW_EMPTY_PASSWORD=${MONGODB_ALLOW_EMPTY_PASSWORD}
- MONGODB_USERNAME=${MONGODB_USERNAME}
- MONGODB_PASSWORD=${MONGODB_PASSWORD}
- MONGODB_DATABASE=${MONGODB_DATABASE}
- MONGODB_ROOT_PASSWORD=${MONGODB_ROOT_PASSWORD}
- MONGODB_EXTRA_FLAGS=${MONGODB_EXTRA_FLAGS}
- MONGODB_ENABLE_JOURNAL=${MONGODB_ENABLE_JOURNAL}
- MONGODB_ENABLE_NUMACTL=${MONGODB_ENABLE_NUMACTL}
- MONGODB_ENABLE_DIRECTORY_PER_DB=${MONGODB_ENABLE_DIRECTORY_PER_DB}
volumes:
- ${MONGODB_REPLICA_ARBITER_HOME}/arbiter:/bitnami/mongodb
networks:
- mongodb_replica
depends_on:
- mongodb-primary
ports:
- ${MONGODB_REPLICA_ARBITER_PORT_27017}:27017
healthcheck:
test: mongosh --eval 'db.runCommand("ping").ok' --quiet
networks:
mongodb_replica:
driver: bridge