首页 > 其他分享 >mongo docker compose

mongo docker compose

时间:2022-12-26 22:57:07浏览次数:45  
标签:compose mongo mongodb entrypoint key docker apollo data

 

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:[email protected]: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

 

标签:compose,mongo,mongodb,entrypoint,key,docker,apollo,data
From: https://www.cnblogs.com/exmyth/p/17007090.html

相关文章

  • 详解如何进入、退出docker容器的方法
    参考地址:https://blog.csdn.net/qq_46416934/article/details/1244909781启动docker服务首先需要知道启动docker服务是:servicedockerstart或者:systemctlstartdoc......
  • docker高级篇:实战-自己开发的微服务怎么在docker上面运行?
    通过前面的一系列学习,我们已经知道怎么制作dockerfile了。那么,本篇文章,咱们就把自己写的springboot的demo项目,部署在docker上面。案例目标:我们自己开发的微服务怎么在do......
  • Docker操作镜像、容器
                                                         ......
  • 关系型数据库学习手记——初见倾心PostgreSQL、MySQL、SQLite、MongoDB
    一、关系型数据库系统理论知识1.1学习笔记​​数据库系统概念读书笔记-引言​​数据库系统概念读书笔记-关系数据库数据库系统概念读书笔记-数据库发展史(上)数据库系统概念......
  • mongodb定时备份
    1、https://www.jianshu.com/p/a9352e28e2d6  (未测试)通过centos脚步来执行备份操作,使用crontab实现定时功能,并删除指定天数前的备份具体操作:1、创建Mongodb数据......
  • 使用docker-compose配置两个wordpress网站时遇到的问题
    考试前两天想给女票也搞个博客,单独测试好好的,一起部署怎么都上不去,关键是理论上完全没问题。。最后调了半天(真·半天)发现是天杀的docker-compose必须mount与nginx一样的路......
  • Docker&K8S传送门
    ​​第一章——Docker(已熟悉的可以从第二章开始)​​​​​第二章——企业部署实战_K8S​​​​​第三章——k8s集群​​​​​第四章——dashboard插件及k8s实战交付​​​......
  • docker环境部署步骤
    前提条件:项目中写有dockerfile文件(dockerfile是用来构建镜像的文件,就一些命令的集合) 1、修改setting.py文件中的数据库配置  2、可使用navicat工具新建一个数据库......
  • docker 镜像使用
    运行容器时,如果镜像在本地不存在,docker就会自动从docker镜像仓库中下载,默认是从dockerHub公共镜像源下载。 1.查看本地镜像dockerimages 1.1通过镜像来运行容......
  • mongodb shell设置
    [root@host-172-16-13-179~]#cat/root/.mongorc.jshost=db.serverStatus().host;cmdCount=1;prompt=function(){returndb+"@"+host+""+(cmdCount++)+">";}func......