Developing with Docker

What is MongoDB?

MongoDB is an open-source, cross-platform, and distributed document-based database designed for ease of application development and scaling. It is a NoSQL database developed by MongoDB Inc.

MongoDB is not a Relational Database Management System (RDBMS). It's called a “NoSQL” database. It is opposite to SQL based databases where it does not normalize data under schemas and tables where every table has a fixed structure. Instead, it stores data in the collections as JSON based documents and does not enforce schemas. It does not have tables, rows, and columns as other SQL (RDBMS) databases.

The following table lists the relation between MongoDB and RDBMS terminologies.

MongoDB (NoSQL Database)
RDBMS (SQL Server, Oracle, etc.)

Database

Database

Collection

Table

Document

Row (Record)

Field

Column

In the RDBMS database, a table can have multiple rows and columns. Similarly, in MongoDB, a collection can have multiple documents which are equivalent to the rows. Each document has multiple “fields” which are equivalent to the columns. Documents in a single collection can have different fields.

The following is an example of JSON based document.

What is MongoExpress?

Mongo Express is an interactive lightweight Web-Based Administrative Tool to effectively manage MongoDB Databases. Written with Node.js, Express, and Bootstrap3, MongoExpress can be used to simplify several MongoDB Admin tasks. Using Mongo Express, you can add, delete or modify databases, collections, and documents.

Installing a MongoDB Docker Container

Installing a MongoExpress Docker Container

Docker Network

Starting the application with Docker

✅ Step 1: Create docker network

✅ Step 2: start mongodb

✅ Step 3: start mongo-express

NOTE: creating docker-network in optional. You can start both containers in a default network. In this case, just emit --net flag in docker run command

✅ Step 4: open mongo-express from browser

✅ Step 5: create my-db db and users collection in mongo-express

✅ Step 6: Start your nodejs application locally - go to app directory of project

Step 7: Access you nodejs application UI from browser

Last updated