Last active
August 18, 2025 09:35
-
-
Save pseudo-usama/cae9ebef54cf5c21e8b733323fdbf8d5 to your computer and use it in GitHub Desktop.
MongoDB Docker setup
This file contains hidden or 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.9" | |
| services: | |
| mongo: | |
| image: mongo:7 | |
| container_name: mongodb | |
| restart: unless-stopped | |
| ports: | |
| - "27017:27017" | |
| environment: | |
| MONGO_INITDB_ROOT_USERNAME: root | |
| MONGO_INITDB_ROOT_PASSWORD: example | |
| volumes: | |
| - mongodb_data:/data/db | |
| mongo-express: | |
| image: mongo-express:latest | |
| container_name: mongo-express | |
| restart: unless-stopped | |
| depends_on: | |
| - mongo | |
| ports: | |
| - "8081:8081" | |
| environment: | |
| ME_CONFIG_MONGODB_SERVER: mongo | |
| ME_CONFIG_MONGODB_ADMINUSERNAME: root | |
| ME_CONFIG_MONGODB_ADMINPASSWORD: example | |
| # Optional: set basic auth for the web UI | |
| ME_CONFIG_BASICAUTH_USERNAME: admin | |
| ME_CONFIG_BASICAUTH_PASSWORD: admin | |
| volumes: | |
| mongodb_data: |
This file contains hidden or 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
| sudo docker compose up -d | |
| sudo docker compose down |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment