Skip to content

Instantly share code, notes, and snippets.

@harsh4870
Created March 1, 2022 20:16
Show Gist options
  • Save harsh4870/4763e53ebe6fa2b0f40633c373addf0d to your computer and use it in GitHub Desktop.
Save harsh4870/4763e53ebe6fa2b0f40633c373addf0d to your computer and use it in GitHub Desktop.
MongoDb docker compose
version: '3.7'
services:
mongodb_container:
image: mongo:latest
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=password
- MONGO_INITDB_DATABASE=test
ports:
- 27017:27017
volumes:
- mongodb_data_container:/data/db
#- ./init-mongo.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
volumes:
mongodb_data_container:
#Give database access to user
#db.createUser( { user: "root", pwd: "password", roles: [ { role: "readWrite", db: "test" }, { role: "read", db: "test" } ] } )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment