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'
  }  
]);
相关推荐
Tian_Hang1 小时前
eclipse ditto 学习笔记
运维·服务器·开发语言·javascript·3d
江畔柳前堤1 小时前
第13章:docker生产环境部署实战
运维·git·docker·容器·代码复审
爱喝水的鱼丶1 小时前
SAP-ABAP:接口 vs 抽象类:ABAP OOP两类扩展方式的差异与选型原则
运维·性能优化·sap·abap·erp·经验交流
iCxhust1 小时前
linux目录是否保存在硬盘 启动后读入解析的
linux·运维·服务器
敖行客 Allthinker2 小时前
企业级多台服务器组装 K3s 高性能集群实战指南
运维·服务器·团队开发
TTBIGDATA3 小时前
【Ambari Plus】10.HBase 安装
大数据·运维·hadoop·ambari·hdp·cdh·bigtop
hj2862513 小时前
Docker 容器化技术标准化笔记
java·笔记·docker
艾伦_耶格宇3 小时前
【ELK】-2 ELK的搭建
运维·elk
xcLeigh4 小时前
KES运维自动化与脚本体系实战
运维·数据库·自动化·脚本·数据迁移·kes
潘正翔4 小时前
docker基础_镜像使用
linux·运维·服务器·docker·容器·centos·devops