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'
  }  
]);
相关推荐
jipinxiaofeihua4 小时前
(文章6) 03章-C++文件操作(下)
linux·运维·网络
饿了吃洗衣凝珠15 小时前
shell
linux·运维·服务器
Decay__16 小时前
PostgreSQL 性能调优方法论 —— pg_stat_statements、EXPLAIN ANALYZE、瓶颈定位流程与参数基线
运维·数据库·sql·postgresql
always202219 小时前
AI运行时 · 06 - Kata 与 K8s 集成:RuntimeClass / CSI kata-directvolume / 性能开销与调优
人工智能·容器·kubernetes
stormsha1 天前
中文路径让 MySQL 起不来:Failed to find valid data directory 与 Illegal byte sequence
运维·数据库·mysql
stormsha1 天前
MySQL 报 `data directory has files in it`:初始化失败一次,之后就永久起不来
运维·数据库·mysql
csdn_aspnet1 天前
使用 Docker 配置 PostgreSQL 和 pgAdmin 4
数据库·docker·postgresql·pgadmin4
Maiko Star1 天前
Docker保姆级部署AI应用程序(FastAPI)
docker·容器·fastapi
沙老师1 天前
Linux Purification Plan - More Modification
linux·运维·服务器
Decay__1 天前
PostgreSQL 高可用与容灾架构 —— 流复制、Patroni、Keepalived+VIP、读写分离与两地三中心
运维·数据库·sql·postgresql