Install Discourse using Docker and Docker Compose

Discourse is a modern, open-source forum and discussion platform designed for community engagement, offering features similar to traditional forums but with a focus on modern web standards and usability.

It’s built to encourage healthy and engaging discussions, making it an ideal platform for communities, product discussions, and more. Discourse is known for its real-time updates, mobile-friendly interface, and extensive customization options, making it popular among developers and community managers.

Key Features of Discourse:

  1. Real-Time Updates: Discourse offers live updates for discussions, eliminating the need to refresh the page to see new posts or changes.
  2. Mobile-Friendly: The platform is fully responsive, working seamlessly on both desktop and mobile devices.
  3. Trust Levels and Moderation: Discourse includes a sophisticated user trust system, which helps manage permissions and encourages community participation. It also provides tools for moderation, spam control, and user management.
  4. Customizable: Discourse can be extensively customized with themes, plugins, and API integrations, allowing it to fit the specific needs of any community.
  5. Rich Text Editor: Users can write posts with a markdown-based editor that supports rich formatting, including images, links, and code snippets.
  6. Notifications and Mentions: Discourse supports @mentions, private messages, and notifications to keep users engaged and informed.
  7. Third-Party Integrations: Discourse integrates with various services such as GitHub, Slack, and others, making it easy to connect with existing workflows and tools.
  8. Security and Privacy: Discourse includes features like two-factor authentication, email verification, and data encryption to ensure secure communication.

How to Install Discourse Using Docker and Docker Compose

Here’s a step-by-step guide to installing Discourse using Docker and Docker Compose:

Create a Directory for Discourse

First, create a directory where you’ll store the Docker Compose configuration and related data.

mkdir discourse-docker
cd discourse-docker

Create a docker-compose.yml File

Create a docker-compose.yml file with the following content:

version: '3'

services:
  redis:
    image: redis:latest
    container_name: discourse_redis
    restart: always

  postgres:
    image: postgres:13
    container_name: discourse_postgres
    restart: always
    environment:
      POSTGRES_DB: discourse
      POSTGRES_USER: discourse
      POSTGRES_PASSWORD: discoursepassword
    volumes:
      - ./pgdata:/var/lib/postgresql/data

  discourse:
    image: discourse/base:latest
    container_name: discourse_app
    restart: always
    depends_on:
      - redis
      - postgres
    ports:
      - "8080:80"
    environment:
      DISCOURSE_HOSTNAME: localhost
      DISCOURSE_DEVELOPER_EMAILS: '[email protected]'
      DISCOURSE_SMTP_ADDRESS: smtp.example.com
      DISCOURSE_SMTP_PORT: 587
      DISCOURSE_SMTP_USER_NAME: your-smtp-username
      DISCOURSE_SMTP_PASSWORD: your-smtp-password
    volumes:
      - ./discourse_data:/var/www/discourse

Configure Environment Variables

Replace the placeholder values ([email protected], smtp.example.com, etc.) with your actual information.

Initialize Discourse

Run the following command to initialize the containers and set up Discourse:

docker-compose up -d

This command will download the necessary Docker images, create the containers, and start the Discourse app.

Access Discourse

Once the containers are up and running, you can access Discourse by navigating to http://localhost:8080 in your web browser.

Finalize Installation

Upon first accessing the Discourse site, you’ll be guided through the final setup steps, including configuring your admin account and additional site settings.

Managing the Containers

To stop the containers, you can use:

docker-compose down

To view the logs:

docker-compose logs -f

This guide provides a simple method to install and run Discourse using Docker and Docker Compose, allowing you to quickly set up a powerful, self-hosted community platform on your local machine or server.








Open-source Apps

9,500+

Medical Apps

500+

Lists

450+

Dev. Resources

900+