Last active
December 24, 2024 06:32
-
-
Save 0xAungkon/9b1819ab1e74c65b1cb67c627742f6da to your computer and use it in GitHub Desktop.
Mongodb Compose File #docker #mongo #node
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
| #rename mongo-compose.yml to compose.yml | |
| version: '3.1' | |
| networks: | |
| db_network: | |
| driver: bridge | |
| ipam: | |
| driver: default | |
| config: | |
| - subnet: 172.18.0.0/16 | |
| # create a docker network | |
| # use `docker network prune` if it's an existing network and you want to recreate it | |
| services: | |
| mongo: | |
| image: mongo #docker image | |
| restart: always | |
| environment: | |
| MONGO_INITDB_ROOT_USERNAME: root # change the username if needed | |
| MONGO_INITDB_ROOT_PASSWORD: example #change the password | |
| ports: | |
| - "27017:27017" # port number | |
| networks: | |
| db_network: | |
| ipv4_address: 172.18.0.6 # Adjust the IP address as needed | |
| volumes: | |
| - ~/db_volume:/data/db # mount ~/dbvolume to docker container |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment