MongoDB
Setting Up MongoDB on Docker Compose
MongoDB is a Document Database, designed to to be used by evolving data schemeas for applications. This allows for developers to store structured or unstructured data easily in a JSON-like format.
For more information about what MongoDB, check out the official website found: https://www.mongodb.com/
Why Choose MongoDB
MongoDB is an easy to navigate database solution, that offers flexibility and functionality for developers with ever changing data schema’s as part of application or service development. Data is stored in a JSON-like format making interaction with data, either updating deleting or adding a much simple process.
Docker Compose Example
Start MongoDB
Now the docker compose file above has had the relevant configuration options set such as HOSTSNI, MongoDB can now be started using the following command:
Post-Installation Steps
After deploying MongoDB, the Reverse Proxy being used will need to be updated to allow access to the MongoDB container externally. In this case Traefik
is the reverse proxy being used so the following line needs to be added into the command section of the configuration:
As an observation, as port 27017 is the “default” port used by MongoDB, it is advised to change the default port to something else or checking the documentation of MongoDB as to what other security measures can be enabled to make the configuration more secure.
Key Components of Docker Compose Configuration Explained
- Image - Specifies the MongoDB server image and tag
- Ports - Exposes MongoDB on specified port
- Volumes - For MongoDB Database file and MongoDB Log files
- Environment - used for MONGODB_INITDB_USERNAME and MONGODB_INITDB_PASSWORD used to create and login to the database.
- Labels - Used by Traefik to provide external access to the service, once the service all its dependancies have been started are
"healthy" and Accessible
, Public Service Name and what provider to use to check and obtain for an SSL Certificate