docker-compose搭建mongodb

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
~                                                                                                                                                                                     

 

你可能感兴趣的:(mongodb)