Getting Started 😈 - lyes-sefiane/microservices-monitoring-and-observability GitHub Wiki
Table Of Contents
What Is MongoDB?
"MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need" [1] .
MongoDB With Docker Environment Setup
version: "3.9"
services:
mongo:
image: mongo
container_name: mongodb
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_USER}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
MONGO_INITDB_DATABASE: ${MONGODB}
ports:
- ${MONGDB_PORT}:${MONGDB_PORT}
volumes:
- ./db/init:/docker-entrypoint-initdb.d
mongo-express:
image: mongo-express
container_name: mongo-express
restart: always
ports:
- ${MONGO_EXPRESS_PORT}:${MONGO_EXPRESS_PORT}
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: ${MONGO_USER}
ME_CONFIG_MONGODB_ADMINPASSWORD: ${MONGO_PASSWORD}
ME_CONFIG_MONGODB_URL: ${MONGODB_URL}
Docker Compose .env File
MONGO_USER=root
MONGO_PASSWORD=example
MONGODB=cooker
MONGODB_URL=mongodb://${MONGO_USER}:${MONGO_PASSWORD}@mongo:27017/
MONGDB_PORT=27017
MONGO_EXPRESS_PORT=8081
Import Data with Mongo Import
mongoimport --db cooker --collection recipes --drop --file /docker-entrypoint-initdb.d/recipes.json --jsonArray
mongoimport --db cooker --collection users --drop --file /docker-entrypoint-initdb.d/users.json --jsonArray
Docker Compose up
lyes-s ( ◥◣_◢◤ ) ~/Documents/learning-mongo $ docker-compose -f mongodb.yml --env-file .env up -d
Creating network "learning-mongo_default" with the default driver
Creating mongodb ...
Creating mongo-express ...
Creating mongo-express ... done
Creating mongodb ... done
Mongo Express
URL : http://localhost:8081/