Skip to content

Instantly share code, notes, and snippets.

@patriciomg
Created March 7, 2021 17:32
Show Gist options
  • Save patriciomg/0e7801526d31ca40df2a74b4f92c6047 to your computer and use it in GitHub Desktop.
Save patriciomg/0e7801526d31ca40df2a74b4f92c6047 to your computer and use it in GitHub Desktop.
This setup allows us to have mongodb and a nice web UI mongo-express running. For additional security, we have set password for our db, and we have also set a web login BASICAUTH for our mongo-express service. (localhost:8081). Spin this up with docker-compose up --build
mongodb:
image: mongo:4.2.5-bionic
container_name: mongodb
restart: always
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=example
volumes:
- './database:/data/db'
ports:
- "27017:27017"
- "27018:27018"
- "27019:27019"
expose:
- 27017
- 27018
- 27019
mongo-express:
image: mongo-express
restart: always
environment:
# mongodb authentication
- ME_CONFIG_MONGODB_ADMINUSERNAME=root
- ME_CONFIG_MONGODB_ADMINPASSWORD=example
# mongodb URI
- ME_CONFIG_MONGODB_SERVER=mongodb
- ME_CONFIG_MONGODB_PORT=27017
# web login username and password
- ME_CONFIG_BASICAUTH_USERNAME=mongo
- ME_CONFIG_BASICAUTH_PASSWORD=express
ports:
- 8081:8081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment