Docker includes a tool called Docker Composethat helps you create multi container applications.We’ll use it to create two containers that will run nodebb and mongodb (named as such respectively). We’ll set nodebb to depend on mongodb container so it will wait for mongodb to run first. This whole docker-compose file lets us write docker run arguments in a config file so we can easily tweak stuff.
Benefits of Docker Compose
Single host deployment – This means you can run everything on a single piece of hardware
Quick and easy configuration – Due to YAML scripts
High productivity – Docker Compose reduces the time it takes to perform tasks
Security – All the containers are isolated from each other, reducing the threat landscape
How to setup Nodebb in a docker container through docker-compose
This works in tandom with a .env file. The env file will hold values of all the variables used here. Please replace them with the name of your website/domain and usernames and password values. This setup will create a user, database and password on mongo db automatically. I like to use bitnami images because they provide comprehensive documentation and maintain there images. You can read their docs here https://github.com/bitnami/bitnami-docker-mongodb.
Example of .env file
#Nodebb specific variables
#Bitnami MongoDB specific variables