Mongo DB docker compose 安装配置

docker-compose.yml

yml 复制代码
version: '3.8'

services:
  
  # Database - Mongo DB
  mongo:
    image: mongo:7.0.0
    restart: on-failure
    environment:
      MONGO_INITDB_ROOT_USERNAME: test
      MONGO_INITDB_ROOT_PASSWORD: test123
    ports:
      - "27017:27017"
    volumes:
      - ./docker-entrypoint-initdb.d/mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
      - ./data/mongodb-data:/data/db
      - ./data/mongodb-log:/var/log/mongodb

/docker-entrypoint-initdb.d/mongo-init.js

js 复制代码
db = db.getSiblingDB('db01');

db.createCollection('test_collection');

db.test_collection.insertMany([
 {
    org: 'helpdev',
    filter: 'EVENT_A',
    addrs: 'http://rest_client_1:8080/wh'
  },
  {
    org: 'helpdev',
    filter: 'EVENT_B',
    addrs: 'http://rest_client_2:8081/wh'
  },
  {
    org: 'github',
    filter: 'EVENT_C',
    addrs: 'http://rest_client_3:8082/wh'
  }  
]);
相关推荐
百***25611 分钟前
Nginx作用以及应用场景
运维·nginx
小徐敲java19 分钟前
window使用phpStudy在nginx部署前端测试
运维·前端·nginx
Crazy________20 分钟前
38nginx四层负载均衡配置,和动静分离解析
linux·运维·nginx·负载均衡
YongCheng_Liang44 分钟前
ELK 自动化部署脚本解析
linux·运维·elk·jenkins
小白博文1 小时前
MobaXterm调用远程服务器(Linux)图形化界面应用
linux·运维·服务器
百***67031 小时前
Nodemailer使用教程:在Node.js中发送电子邮件
linux·运维·node.js
TG:@yunlaoda360 云老大1 小时前
谷歌云发布 Document AI Workbench 最新功能:自定义文档拆分器实现复杂文档处理自动化
运维·人工智能·自动化·googlecloud
凄戚2 小时前
docker 镜像失效问题
运维·docker·容器
岚天start2 小时前
K8S中nodePort、port和 targetPort的区别
云原生·容器·kubernetes
xingyue_S3 小时前
LVS负载均衡群集(二)-- DR模式
运维·负载均衡·lvs