Guest User

docker-compose.yml

a guest
Nov 23rd, 2023
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.93 KB | None | 0 0
  1. version: "3.9"
  2. services:
  3.   mongo1:
  4.     hostname: mongo1
  5.     image: mongo:6
  6.     ports:
  7.      - 3001:27017
  8.     environment:
  9.      - MONGO_INITDB_ROOT_USERNAME=root
  10.       - MONGO_INITDB_ROOT_PASSWORD=password
  11.       - MONGO_INITDB_DATABASE=db
  12.     entrypoint: [ "mongod", "--bind_ip_all", "--replSet", "rs0" ]
  13.     volumes:
  14.      - ./data/db1:/data/db
  15.     restart: always
  16.     healthcheck:
  17.       test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
  18.       interval: 10s
  19.       timeout: 10s
  20.       retries: 5
  21.       start_period: 30s
  22.   mongo2:
  23.     hostname: mongo2
  24.     image: mongo:6
  25.     ports:
  26.      - 3002:27017
  27.     environment:
  28.      - MONGO_INITDB_ROOT_USERNAME=root
  29.       - MONGO_INITDB_ROOT_PASSWORD=password
  30.       - MONGO_INITDB_DATABASE=db
  31.     entrypoint: [ "mongod", "--bind_ip_all", "--replSet", "rs0" ]
  32.     volumes:
  33.      - ./data/db2:/data/db
  34.     restart: always
  35.     healthcheck:
  36.       test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
  37.       interval: 10s
  38.       timeout: 10s
  39.       retries: 5
  40.       start_period: 30s
  41.   mongo3:
  42.     hostname: mongo3
  43.     image: mongo:6
  44.     ports:
  45.      - 3003:27017
  46.     environment:
  47.      - MONGO_INITDB_ROOT_USERNAME=root
  48.       - MONGO_INITDB_ROOT_PASSWORD=password
  49.       - MONGO_INITDB_DATABASE=db
  50.     entrypoint: [ "mongod", "--bind_ip_all", "--replSet", "rs0" ]
  51.     volumes:
  52.      - ./data/db3:/data/db
  53.     restart: always
  54.     healthcheck:
  55.       test: echo 'db.runCommand("ping").ok' | mongosh localhost:27017/test --quiet
  56.       interval: 10s
  57.       timeout: 10s
  58.       retries: 5
  59.       start_period: 30s
  60.   mongo-rs-initiator:
  61.     image: mongo:6
  62.     entrypoint: [ "bash", "/opt/rs-init.sh" ]
  63.     volumes:
  64.      - ./rs-init.sh:/opt/rs-init.sh:ro
  65.     restart: no
  66.     depends_on:
  67.       mongo1:
  68.         condition: service_healthy
  69.       mongo2:
  70.         condition: service_healthy
  71.       mongo3:
  72.         condition: service_healthy
Advertisement
Add Comment
Please, Sign In to add comment