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

前端 未结 8 2115
情话喂你
情话喂你 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:18

    Some updates in new verion of mongo-express, the accepted solution doesn't work any more, especially you need fix this issue

    TypeError: Cannot read property 'listDatabases' of undefined
    

    Tips

    Do remember, if you adjust the setting, restart it with option --force-recreate.

    docker-compose up --force-recreate -d
    

    Here is the docker-compose.yml I am using currently.

    version: '3'
    
    services:
        mongo:
            image: mongo:${MONGO_TAG}
            environment:
                - MONGO_INITDB_ROOT_USERNAME=${MONGO_ROOT_USER}
                - MONGO_INITDB_ROOT_PASSWORD=${MONGO_ROOT_PASSWORD}
                - MONGO_INITDB_DATABASE=project
        mongo-express:
            image: mongo-express
            environment:
                - ME_CONFIG_MONGODB_SERVER=mongo
                - ME_CONFIG_MONGODB_PORT=27017
                - ME_CONFIG_MONGODB_ENABLE_ADMIN=true
                - ME_CONFIG_MONGODB_AUTH_DATABASE=admin
                - ME_CONFIG_MONGODB_ADMINUSERNAME=${MONGO_ROOT_USER}
                - ME_CONFIG_MONGODB_ADMINPASSWORD=${MONGO_ROOT_PASSWORD}
                - ME_CONFIG_BASICAUTH_USERNAME=${MONGOEXPRESS_LOGIN}
                - ME_CONFIG_BASICAUTH_PASSWORD=${MONGOEXPRESS_PASSWORD}
            links:
                - mongo
            ports:
              - "8081:8081"
    

提交回复
热议问题