mongo docker compose

 

49dSsULIAv6NiP8hdqqbapRTHVx9BRYU4VVakN9A4FJWV0KufqEm/UoTUvn9Z4eg
FRP7iHXF6Qiou5MK2Ak76zRBU7MOIVCl0DIhrPoQN/mJFW4XaP/N1m6ElblMuqqi
k4jUWWXxXiCZFlaxJHPEyH1oifO2MrUdv2yhdNltrMtPvweqEzJc6fX1EgXUKPgR
h4kchu9BUr+PkQXtx4qP4YKRgn7AAW3pxeNWqXBQp/9VOYa6EupbiQrMRV8OvAv2
lqIVEm0lSj+Kyl4v55nwD2GTO0+dNcujk0tnEc58YbJJ6nPNPbgM93CVw/taRkHZ
lzIRI+Gnmtjy3qE2MhHS92dN0Mc2OKu6NkZjuUo6YINbkRsdMBpTDAXqVigAoOrz
EUFJvjXO7gHam6r2qYvojnp/JeBmabR1A3DZXTUck+puyB2HiiAKri2DwcoujKPl
47cWxGkDvstupj5qdecB9n6y/fKmfsqKCvlFWtUXT0ONJ/xTDyhGHIks1GtkKsvx
/rHOOGehrCr+jJx+I+PQ+Pm7lmTrI9ju5ckeOZUjhjN19ubjTqlKGl1KH7g5q1D/
8US51ggme56tC445+9rHZqj0cVVP8JPfj1YVPRskpzyNf9lXy5ag3NfnkxKF+Qyn
rtgagkoXNNJDh96z6YXxCjrQeGxEqZYfPLXX6gaDzQEOc2K7nad+LPRxhZxeoub8
YhZHLT3oELlKq3Tz6c5UD3q4lmyydynY02txr/iUegLs4VqiYBveYOxJhhngfRUT
SseTzS+CJ0qhmAOWsHmfDWEN1e2Ls06rHqKSiX02pgQWR+BHksCHoGwKSl8424ul
Qs8bDeLJA36PY8tSthtjcKEz9BmLQ7kU5Fdf6wkrBKQ/s3WNSd3zAN7eFjeUJale
GqXdd3tLZPXNPKhw1/yyJHZy2hy4z5usPAnSkDwbwLJCnpXorrExI9a3dq9K3du7
WdSo/RqKlzjm0BPVyJaSoYMXikN18eV7/NMAU/92r9adJmfW

 

 

version: '3'
services:
  mongo1:
    image: mongo:4.4.17 # mongo_image_version
    volumes:
      - /etc/localtime:/etc/localtime
      - /home/finance/apollo/data/mongo/db1:/data/db # mongo1_data
      - ./mount/mongodb.key:/data/mongodb.key
      - ./mount/create_user.sh:/data/create_user.sh
      - ./mount/init:/docker-entrypoint-initdb.d
    user: root
    environment:
      MONGO_INITDB_ROOT_USERNAME: "admin"
      MONGO_INITDB_ROOT_PASSWORD: "123456"
      MONGO_INITDB_DATABASE: "admin"
    container_name: apollo_mongo1
    ports:
      - 28017:27017    # mongo1_port
    command: mongod --replSet mongos --keyFile /data/mongodb.key
    restart: always
    networks:
      - apollo
    entrypoint:
      - bash
      - -c
      - |
        chmod 400 /data/mongodb.key
        chown 999:999 /data/mongodb.key
        exec docker-entrypoint.sh $$@

  mongo2:
    image: mongo:4.4.17 # mongo_image_version
    volumes:
      - /etc/localtime:/etc/localtime
      - /home/finance/apollo/data/mongo/db2:/data/db # mongo2_data
      - ./mount/mongodb.key:/data/mongodb.key
      - ./mount/init:/docker-entrypoint-initdb.d
    user: root
    environment:
      MONGO_INITDB_ROOT_USERNAME: "admin"
      MONGO_INITDB_ROOT_PASSWORD: "123456"
      MONGO_INITDB_DATABASE: "admin"
    container_name: apollo_mongo2
    ports:
      - 28018:27017    # mongo2_port
    command: mongod --replSet mongos --keyFile /data/mongodb.key
    restart: always
    networks:
      - apollo
    entrypoint:
      - bash
      - -c
      - |
        chmod 400 /data/mongodb.key
        chown 999:999 /data/mongodb.key
        exec docker-entrypoint.sh $$@

  mongo3:
    image: mongo:4.4.17 # mongo_image_version
    volumes:
      - /etc/localtime:/etc/localtime
      - /home/finance/apollo/data/mongo/db3:/data/db # mongo3_data
      - ./mount/mongodb.key:/data/mongodb.key
      - ./mount/init:/docker-entrypoint-initdb.d
    user: root
    environment:
      MONGO_INITDB_ROOT_USERNAME: "admin"
      MONGO_INITDB_ROOT_PASSWORD: "123456"
      MONGO_INITDB_DATABASE: "admin"
    container_name: apollo_mongo3
    ports:
      - 28019:27017    # mongo3_port
    command: mongod --replSet mongos --keyFile /data/mongodb.key
    restart: always
    networks:
      - apollo
    entrypoint:
      - bash
      - -c
      - |
        chmod 400 /data/mongodb.key
        chown 999:999 /data/mongodb.key
        exec docker-entrypoint.sh $$@
  mongo0:
    image: mongo:4.4.17 # mongo_image_version
    container_name: apollo_mongo0
    depends_on:
      - mongo1
      - mongo2
      - mongo3
    restart: on-failure:5
    networks:
      - apollo
    volumes:
        - ./mount/init:/docker-entrypoint-initdb.d
    command:
      - mongo
      - mongodb://admin:123456@192.168.10.153:28017/admin # mongo_connect
      - --eval
      - 'rs.initiate({ _id: "mongos", members:  [{_id:1,host:"192.168.10.153:28017"},{_id:2,host:"192.168.10.153:28018"},{_id:3,host:"192.168.10.153:28019"}]})' # mongo_config

networks:
  apollo:
    driver: bridge

 

posted @ 2022-12-26 22:35  牧之丨  阅读(34)  评论(0编辑  收藏  举报