Introduction to MongoDB
Last weekend I participated in a hack day with some colleagues and one of them decided that it would be a good idea to use MongoDB. Since I had never used it, I thought it would be fun to learn a little about it. Here I’m going to write about the things that I learned.
Installation
I chose to use Docker because it makes everything easier. The only thing to keep in mind when using Docker for a database is that you need to store the data files outside the container so they don’t disappear when the container is destroyed. This is enough to get the MongoDB running in a container and making sure the data is persisted in $(PWD)/data in the host:
1
docker run --name my-mongo -v $(PWD)/data:/data/db -d mongo:3.3
First steps
Once we have mongo running we need to open a shell in the running container so we can play with it: