Last active
August 8, 2021 16:35
-
-
Save malikperang/bd8bf81558e4679085e2f9248f73e085 to your computer and use it in GitHub Desktop.
MongoDB Docker Compose
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: "fariz", | |
pwd: "admin321", | |
roles:[ | |
{ | |
role: "readWrite", | |
db: "admin" | |
} | |
] | |
} | |
); |
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.8" | |
services: | |
mongodb: | |
image : mongo | |
container_name: mongodb | |
environment: | |
MONGO_INITDB_ROOT_USERNAME: admin | |
MONGO_INITDB_ROOT_PASSWORD: admin321 | |
MONGO_INITDB_DATABASE: admin | |
MONGODB_USER: admin | |
MONGODB_PASSWORD: admin321 | |
MONGODB_DATABASE: admin | |
volumes: | |
- ./home/mongodb:/home/mongodb | |
- ./data:/data/db | |
- ./script/create-user.js:/docker-entrypoint-initdb.d/create-user.js:ro | |
command: [--auth] | |
ports: | |
- 27017:27017 | |
restart: unless-stopped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment