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