docker-compose搭建mongodb

刁浩言
2023-12-01
version: '2'
services:
    mongodb:
        image: mongo:latest
        container_name: "mongodb"
        restart: always
        environment:
            - MONGO_DATA_DIR=/data/db
            - MONGO_LOG_DIR=/data/logs
            - MONGO_INITDB_ROOT_USERNAME=admin
            - MONGO_INITDB_ROOT_PASSWORD=123.com
        volumes:
            - ./mongodb/data:/data/db
            - ./mongodb/logs:/data/logs
        ports:
            - 27017:27017
~                                                                                                                                                                                     

 

 类似资料: