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'
  }  
]);
相关推荐
少妇的美梦21 小时前
logstash教程
运维
容器魔方1 天前
Bloomberg 正式加入 Karmada 用户组!
云原生·容器·云计算
chen9451 天前
k8s集群部署vector日志采集器
运维
chen9451 天前
aws ec2部署harbor,使用s3存储
运维
muyun28001 天前
Docker 下部署 Elasticsearch 8 并集成 Kibana 和 IK 分词器
elasticsearch·docker·容器
東雪蓮☆1 天前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
qq_264220891 天前
LVS负载均衡群集和LVS+Keepalived群集
运维·负载均衡·lvs
乌萨奇也要立志学C++1 天前
【Linux】进程概念(二):进程查看与 fork 初探
linux·运维·服务器
雨落Liy1 天前
Nginx 从入门到进阶:反向代理、负载均衡与高性能实战指南
运维·nginx·负载均衡
Nazi61 天前
k8s的dashboard
云原生·容器·kubernetes