I try to run MongoDB and Mongo-express by Docker-compose. I use following config:
version: \'3\'
services:
mongo:
image: mongo
environment:
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
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"