快速启动mongodb和mongo-express
文档说明:只记录关键地方;
试验环境: linux debian 11
mongodb和mongo-webUI
version: "3"
services:
mongodb-server:
image: mongo:latest
container_name: mongodb
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
ports:
- "27017:27017"
volumes:
- ./mongodb-data:/data/db
mongo-express:
image: mongo-express:latest
container_name: mongo-express
depends_on:
- mongodb-server
ports:
- "8081:8081"
environment:
ME_CONFIG_MONGODB_SERVER: mongodb-server # 服务名称
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
ME_CONFIG_BASICAUTH_USERNAME: "admin"
ME_CONFIG_BASICAUTH_PASSWORD: "admin"
启动、关闭、查看日志
# 启动
docker-compose -f docker-compose.yaml up -d
# 关闭
docker-compose -f docker-compose.yaml down --remove-orphans
# 查看日志
docker-compose -f docker-compose.yaml logs -f