This is the backend of the following frontend: https://github.com/JenishaSanjida/henna-tale.git
- src/
- controllers/
- appointment.js
- auth.js
- user.js
- models/
- appointment.js
- portfolio.js
- rating.js
- review.js
- user.js
- day.js
- timeslot.js
- routes/
- appointment.js
- auth.js
- user.js
- utils/
- jwt.js
- app.js
- config.js
- server.jsIf you want to persist the data on your local machine, you can mount a volume using the -v argument.
# create mongodb_data directory with writable permission by docker process
mkdir -m 777 mongodb_data
export MONGODB_VERSION=6.0-ubi8
docker run --name mongodb -d -p 27017:27017 -v $(pwd)/data:/data/db mongodb/mongodb-community-server:$MONGODB_VERSIONUsing this method, you will be able to connect to your MongoDB instance on mongodb://localhost:27017. You can try it with Compass, MongoDB’s GUI to visualize and analyze your data.
Any data created as part of the lifecycle of that container will be destroyed once the container is deleted. You can do that with the Docker stop and rm commands.
docker stop mongodb && docker rm mongodb# docker-compose.yaml
version: "3"
services:
myapplication:
image: mongodb/mongodb-community-server:6.0-ubi8
environment:
- CONN_STR=mongodb://user:pass@mongodb
command: '/bin/bash -c "sleep 5; mongosh $$CONN_STR --eval \"show dbs;\""'
depends_on:
- mongodb
mongodb:
image: mongodb/mongodb-community-server:6.0-ubi8
environment:
- MONGO_INITDB_ROOT_USERNAME=user
- MONGO_INITDB_ROOT_PASSWORD=pass
volumes:
- type: bind
source: ./data
target: /data/dbgit clone https://github.com/shahnawaz-pabon/henna-server.git
cd henna-server
docker-compose up --buildMongoose couldn't connect to the mongodb as I had a volume which didn't have root user. That's why I had to remove my volume to connect mongodb successfully.
docker-compose stop
docker-compose rm
docker volume rm <your-volume>
docker-compose up --build -d# see last 2 hour's logs
docker logs --since=2h <container_id>