What is Docker Compose and why use it here?

Docker includes a tool called Docker Compose that 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

version: '3.3'
services:
    nodebb:
        container_name: nodebb
        ports:
            - "4678:4678"
        volumes:
            - /Users/faisal/volumes/nodebb:/data
        environment:
            - URL=http://localhost:4678
            - DB_HOST=mongodb:27017
            - DATABASE=mongo
            - DB_PORT=27017
        image: 'nibrev/nodebb:stable'
        depends_on:
            - mongodb
        links:
            - mongodb
    mongodb:
        container_name: mongodb
        image: 'docker.io/bitnami/mongodb:4.4-debian-10'
        ports:
            - "27017:27017"
        volumes:
            - '/Users/faisal/volumes/nodebb_mongodb_data:/bitnami/mongodb'
volumes:
    nodebb_mongodb_data:
        driver: local
nodebb mongo docker-compose
Detailed information

Benefits of developing on nodebb through docker

This approach is recommended for development setups only

  • Auto installation
  • Automatic Nodebb and Mongodb version updates

  • Auto upgrade when you update image
  • Persistent storage support
  • Easily setup multiple forums
  • No need for a database server
  • Docker configs in Docker compose so need to remember parameters