Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- version: "3.9"
- services:
- mongo1:
- hostname: mongo1
- image: mongo:6
- ports:
- - 3001:27017
- environment:
- - MONGO_INITDB_ROOT_USERNAME=root
- - MONGO_INITDB_ROOT_PASSWORD=password
- - MONGO_INITDB_DATABASE=db
- entrypoint: [ "mongod", "--bind_ip_all", "--replSet", "rs0" ]
- volumes:
- - ./data/db1:/data/db
- restart: always
- healthcheck:
- test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
- interval: 10s
- timeout: 10s
- retries: 5
- start_period: 30s
- mongo2:
- hostname: mongo2
- image: mongo:6
- ports:
- - 3002:27017
- environment:
- - MONGO_INITDB_ROOT_USERNAME=root
- - MONGO_INITDB_ROOT_PASSWORD=password
- - MONGO_INITDB_DATABASE=db
- entrypoint: [ "mongod", "--bind_ip_all", "--replSet", "rs0" ]
- volumes:
- - ./data/db2:/data/db
- restart: always
- healthcheck:
- test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
- interval: 10s
- timeout: 10s
- retries: 5
- start_period: 30s
- mongo3:
- hostname: mongo3
- image: mongo:6
- ports:
- - 3003:27017
- environment:
- - MONGO_INITDB_ROOT_USERNAME=root
- - MONGO_INITDB_ROOT_PASSWORD=password
- - MONGO_INITDB_DATABASE=db
- entrypoint: [ "mongod", "--bind_ip_all", "--replSet", "rs0" ]
- volumes:
- - ./data/db3:/data/db
- restart: always
- healthcheck:
- test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
- interval: 10s
- timeout: 10s
- retries: 5
- start_period: 30s
- mongo-rs-initiator:
- image: mongo:6
- entrypoint: [ "bash", "/opt/rs-init.sh" ]
- volumes:
- - ./rs-init.sh:/opt/rs-init.sh:ro
- restart: no
- depends_on:
- mongo1:
- condition: service_healthy
- mongo2:
- condition: service_healthy
- mongo3:
- condition: service_healthy
Advertisement
Add Comment
Please, Sign In to add comment