生成密鑰文件
?
openssl rand -base64 756 > mongodb.key
chmod 400 mongodb.key # 權限必須為400?:ml-citation{ref="4" data="citationList"}
chown 999:999 mongodb.key # MongoDB容器用戶ID為999?:ml-citation{ref="4" data="citationList"}?
docker-compose文件
version: '3.8'
services:mongo1:image: mongo:latestcontainer_name: mongo1restart: alwaysports:- "27017:27017"volumes:- ./mongo1/data:/data/db- ./mongodb.key:/etc/mongo/mongodb.key # 掛載密鑰文件?:ml-citation{ref="2,3" data="citationList"}environment:MONGO_INITDB_ROOT_USERNAME: rootMONGO_INITDB_ROOT_PASSWORD: exam