How to run MongoDB and Mongo-express with docker-compose?

前端 未结 8 2136
情话喂你
情话喂你 2021-02-14 07:10

I try to run MongoDB and Mongo-express by Docker-compose. I use following config:

version: \'3\'

services:
    mongo:
        image: mongo
        environment:
         


        
8条回答
  •  佛祖请我去吃肉
    2021-02-14 08:12

    Although this post is bit old. I would like to share the docker-compose.yml that worked for me.

    The below spins up a mongoDB instance and mongo-express.

    version: '3.7'
    services:
      mongo_db:
        image: mongo:4.2.12
        environment:
          MONGO_INITDB_ROOT_USERNAME: root
          MONGO_INITDB_ROOT_PASSWORD: rootpassword
        ports:
          - 27017:27017
        volumes:
          - /C/Mine/mongoData:/data/db
    
      mongo_express:
        image: mongo-express:0.54.0
        environment:
          - ME_CONFIG_OPTIONS_EDITORTHEME=default
          - ME_CONFIG_MONGODB_SERVER=mongo_db
          - ME_CONFIG_MONGODB_PORT=27017
          - ME_CONFIG_MONGODB_ENABLE_ADMIN=true
          - ME_CONFIG_MONGODB_AUTH_DATABASE=mydb
          - ME_CONFIG_MONGODB_ADMINUSERNAME=root
          - ME_CONFIG_MONGODB_ADMINPASSWORD=rootpassword
        ports:
          - "8081:8081"
        restart: on-failure
        depends_on:
          - mongo_db
    

提交回复
热议问题