A Docker compose to learn about MongoDB noSQL database.
With MongoExpress webUI (written with Node.js and express).
Docs:
git clone https://gist.github.com/craig-m-unsw/4057ce9c7407622a41fb0edd8e2c0a5d mongodb-learn
mongodb-learn/
├── docker-compose.yml
└── README.md
Start the DB.
docker-compose up -d
docker ps
Vagrant VM:
vagrant init -m generic/ubuntu2004
vagrant up
vagrant ssh --command "sudo apt-get update && sudo apt-get install -y -q docker.io docker-compose"
vagrant ssh --command "sudo gpasswd -a vagrant docker"
scp -F /dev/stdin < <(vagrant ssh-config) -v *.{yml,yaml,md} vagrant@default:/home/vagrant/
vagrant ssh -- -L 8081:127.0.0.1:8081 -t tmux
docker-compose up -d
docker-compose logs -f
Login to http://localhost:8081 for the WebUI.
No username or pass is required.
Login to Mongo DB shell:
dbid=$(docker ps | grep -e 'mongo' | grep -v 'express' | awk '{ print $1 }');
docker exec -it ${dbid} bash;
mongosh --username root --password rootpass mongodb://mongodb:27017/
Show current DB
test> db
Show databases:
test> show dbs
Get stats on current DB:
test> db.stats()
Create a collection:
test> db.createCollection('foobar')
List all collections:
test> db.getCollectionNames()