My helper for creating a docker container running mongo where i set the super and then create a user. I also want the data to persist so i have added a volume
Last active
September 16, 2021 03:01
-
-
Save aaronksaunders/06b1808e95440e32ed74e7d38161a86d to your computer and use it in GitHub Desktop.
Docker With Mongo
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: | |
mongodb: | |
image: mongo:4.2 | |
environment: | |
MONGO_INITDB_ROOT_USERNAME: aks_root | |
MONGO_INITDB_ROOT_PASSWORD: aks_root | |
ports: | |
- '27017:27017' | |
volumes: | |
- db_data:/data/db | |
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro | |
volumes: | |
db_data: |
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
conn = new Mongo(); | |
db = conn.getDB("test-database"); | |
db.createUser( | |
{ | |
user: "test-user", | |
pwd: "test-password", | |
roles: [ | |
{ | |
role: "dbOwner", | |
db: "test-database" | |
} | |
] | |
} | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment