📜  docker-compose mongodb 副本 - 任何代码示例

📅  最后修改于: 2022-03-11 14:59:33.840000             🧑  作者: Mango

代码示例1
version: '3'
    services:
    
      mongodb1:
        image: mongo:latest
        networks:
          - alphanetwork
        volumes:
          - data1:/data/db
          - config1:/data/configdb
        ports:
          - 30001:27017
        entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
    
      mongodb2:
        image: mongo:latest
        networks:
          - alphanetwork
        ports:
          - 30002:27017
        entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
    
      mongodb3:
        image: mongo:latest
        networks:
          - alphanetwork
        ports:
          - 30003:27017
        entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
    
      mongoclient:
        image: mongo
        networks:
          - alphanetwork
        depends_on:
          - mongodb1
          - mongodb2
          - mongodb3
        volumes:
          - ./deployment_scripts:/deployment_scripts
        entrypoint:
          - /deployment_scripts/initiate_replica.sh
    
    networks:
      alphanetwork:
    
    volumes:
      data1:
      config1: