Skip to content

Instantly share code, notes, and snippets.

@0xAungkon
Last active December 24, 2024 06:32
Show Gist options
  • Select an option

  • Save 0xAungkon/9b1819ab1e74c65b1cb67c627742f6da to your computer and use it in GitHub Desktop.

Select an option

Save 0xAungkon/9b1819ab1e74c65b1cb67c627742f6da to your computer and use it in GitHub Desktop.
Mongodb Compose File #docker #mongo #node
#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