-
-
Save emmanuelnk/1dce0abb1de548bd4992fa467ad588ff to your computer and use it in GitHub Desktop.
docker-compose mongodb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
database: | |
image: 'mongo' | |
container_name: 'my-mongo-container' # give your contatner a name | |
environment: | |
- MONGO_INITDB_DATABASE=your-database-name # database name you want to make | |
- MONGO_INITDB_ROOT_USERNAME=my-container-root-username # set your container root username | |
- MONGO_INITDB_ROOT_PASSWORD=secret # set your contatner root password | |
volumes: | |
- ./init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro | |
- ./mongo-volume:/data/db | |
ports: | |
- '27017-27019:27017-27019' | |
# ... other configs ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.createUser( | |
{ | |
user: "YourUsername", | |
pwd: "“YourPasswordHere", | |
roles: [ | |
{ | |
role: "readWrite", | |
db: "your-database-name" | |
} | |
] | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment