Browse Source

create docker-compose mongo replica

master
zeus 4 years ago
parent
commit
c9a45b8601
  1. 52
      docker-compose.yml

52
docker-compose.yml

@ -19,13 +19,13 @@ services:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
depends_on:
- mongo1
- mongo2
- mongo3
- swarmlabmongo1
- swarmlabmongo2
- swarmlabmongo3
mongo1:
hostname: 'mongo1'
container_name: 'mongo1'
swarmlabmongo1:
hostname: 'swarmlabmongo1'
container_name: 'swarmlabmongo1'
image: 'mongo:4.2'
restart: 'on-failure'
command: ["-f", "/etc/mongod.conf", "--keyFile", "/auth/file.key", "--replSet", "${MONGO_REPLICA_SET_NAME}", "--bind_ip_all"]
@ -36,8 +36,8 @@ services:
networks:
- netSwarmlabMongo
volumes:
- mongoData1:/data/db
- mongoLog1:/var/log/mongodb
- swarmlabmongoData1:/data/db
- swarmlabmongoLog1:/var/log/mongodb
- ./.docker/mongodb/initdb.d/:/docker-entrypoint-initdb.d/
- ./.docker/mongodb/mongod.conf:/etc/mongod.conf
- ./.docker/mongodb/file.key:/auth/file.key
@ -52,9 +52,9 @@ services:
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE}
mongo2:
hostname: 'mongo2'
container_name: 'mongo2'
swarmlabmongo2:
hostname: 'swarmlabmongo2'
container_name: 'swarmlabmongo2'
image: 'mongo:4.2'
command: ["-f", "/etc/mongod.conf", "--keyFile", "/auth/file.key", "--replSet", "${MONGO_REPLICA_SET_NAME}", "--bind_ip_all"]
restart: 'on-failure'
@ -65,8 +65,8 @@ services:
networks:
- netSwarmlabMongo
volumes:
- mongoData2:/data/db
- mongoLog2:/var/log/mongodb
- swarmlabmongoData2:/data/db
- swarmlabmongoLog2:/var/log/mongodb
- ./.docker/mongodb/mongod.conf:/etc/mongod.conf
- ./.docker/mongodb/file.key:/auth/file.key
env_file:
@ -76,11 +76,11 @@ services:
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE}
depends_on:
- mongo1
- swarmlabmongo1
mongo3:
hostname: 'mongo3'
container_name: 'mongo3'
swarmlabmongo3:
hostname: 'swarmlabmongo3'
container_name: 'swarmlabmongo3'
image: 'mongo:4.2'
command: ["-f", "/etc/mongod.conf", "--keyFile", "/auth/file.key", "--replSet", "${MONGO_REPLICA_SET_NAME}", "--bind_ip_all"]
restart: 'on-failure'
@ -91,8 +91,8 @@ services:
networks:
- netSwarmlabMongo
volumes:
- mongoData3:/data/db
- mongoLog3:/var/log/mongodb
- swarmlabmongoData3:/data/db
- swarmlabmongoLog3:/var/log/mongodb
- ./.docker/mongodb/mongod.conf:/etc/mongod.conf
- ./.docker/mongodb/file.key:/auth/file.key
env_file:
@ -102,15 +102,15 @@ services:
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE}
depends_on:
- mongo1
- swarmlabmongo1
volumes:
mongoData1:
mongoData2:
mongoData3:
mongoLog1:
mongoLog2:
mongoLog3:
swarmlabmongoData1:
swarmlabmongoData2:
swarmlabmongoData3:
swarmlabmongoLog1:
swarmlabmongoLog2:
swarmlabmongoLog3:
networks:
netSwarmlabMongo:

Loading…
Cancel
Save