Mattermost is a powerful open-source collaboration tool that can be deployed in various ways, including using Docker for easy setup and management.

This tutorial will guide you through setting up Mattermost on Debian 12 using Docker, with an external PostgreSQL database configured in host network mode and without setting up Nginx.

Prerequisites

Before proceeding, ensure you have the following:

Debian 12 installed and updated.

Docker and Docker Compose installed. You can install Docker by following these commands

sudo apt update sudo apt install -y docker.io docker-compose
sudo systemctl start docker sudo systemctl enable docker

Sufficient resources for Mattermost, at least 4GB of RAM and a modern CPU.

Step 1, Create a .env File for Configuration

First, create a .env file to store all your credentials and configuration:

sudo vi .env

Add the following content to the .env file:

# APP mattermost
MM_ENABLE_OPEN_SERVER=true
MM_USERNAME=admin
MM_PASSWORD=dummypassword123
MM_DB_TYPE=postgres
MM_HTTP_PORT=8065

# DB postgres
POSTGRES_USER=dummyuser
POSTGRES_PASSWORD=dummypassword456
POSTGRES_DB=dummydb
POSTGRES_HOST=localhost
POSTGRES_PORT=5432

Ensure the POSTGRES_HOST is set to localhost because the host network mode allows the container to communicate directly with services running on the host.

Step 2: Create a Docker Compose File

Create a directory for Mattermost and navigate to it:

mkdir -p ~/mattermost-docker && cd ~/mattermost-docker

Create a docker-compose.yml file:

nano docker-compose.yml

Paste the following configuration into the file:

version: '3.8'

services:
  mattermost:
    image: mattermost/mattermost-team-edition:latest
    container_name: mattermost
    network_mode: "host"
    ports:
      - "${MM_HTTP_PORT}:${MM_HTTP_PORT}"
    environment:
      - MM_USERNAME=${MM_USERNAME}
      - MM_PASSWORD=${MM_PASSWORD}
      - MM_ENABLE_OPEN_SERVER=${MM_ENABLE_OPEN_SERVER}
      - MM_DB_TYPE=${MM_DB_TYPE}
      - MM_SQLSETTINGS_DRIVERNAME=postgres
      - MM_SQLSETTINGS_DATASOURCE=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}?sslmode=disable&connect_timeout=10
    volumes:
      - mattermost-data:/mattermost/data
      - mattermost-logs:/mattermost/logs
      - mattermost-config:/mattermost/config
    restart: unless-stopped

volumes:
  mattermost-data:
  mattermost-logs:
  mattermost-config:

The network_mode: "host" setting ensures that the container uses the host’s network stack, allowing it to connect directly to the external PostgreSQL database.

Step 3, Start Mattermost with Docker Compose

Run the following command to start Mattermost:

sudo docker-compose up -d

Docker Compose will download the Mattermost image and start the service. This may take a few minutes if you’re running it for the first time.

Step 4, Verify Mattermost is Running

Check the running containers:

sudo docker ps

You should see a container named mattermost running. To verify further, open your web browser and navigate to:

http://<your-server-ip>:8065

You should see the Mattermost setup page.

Step 5: Configure Initial Setup

In many case, when the application is open from web, the first user is the admin user. Make sure you access in incognito mode, because sometime cache is making the first resgistration page is not working.

In other case maybe you can input the admin user and password form .env file

Username: admin

Password: dummypassword123

Follow the on-screen instructions to complete the setup.

Step 6: Managing the Mattermost Service

To stop Mattermost, run:

sudo docker-compose down

To restart Mattermost, run:

sudo docker-compose up -d

Comparing Mattermost Team Edition and Enterprise Edition

When choosing between the Team Edition and Enterprise Edition of Mattermost, it’s important to understand their differences:

FeatureTeam EditionEnterprise Edition
CostFreeRequires a paid license
User LimitsUnlimited usersUnlimited users
Core Collaboration FeaturesIncludedIncluded
Compliance & AuditingNot availableAvailable
Advanced User ManagementNot availableAvailable
High AvailabilityNot supportedSupported
Priority SupportCommunity support onlyEnterprise-grade support
Performance MonitoringBasicAdvanced
Custom IntegrationsLimitedAdvanced integrations

What are Custom Integrations?

Custom integrations refer to the ability to extend and connect Mattermost with other tools and services to meet specific organizational needs. Here’s how they differ between the Team and Enterprise editions:

  • Team Edition:
    • Limited integrations are available.
    • Supports basic webhook functionality to send and receive messages between Mattermost and external systems.
    • Can integrate with common tools such as Slack-compatible bots and integrations.
  • Enterprise Edition:
    • Offers advanced integration capabilities, including API access for deeper customization.
    • Supports Single Sign-On (SSO) with SAML, LDAP, or Active Directory.
    • Includes advanced webhook functionalities and allows for building highly customized workflows.
    • Enhanced scalability to manage integrations across large teams or multiple departments.

If your organization relies on complex workflows, custom bots, or needs tight integration with enterprise systems, the Enterprise Edition may be necessary. Otherwise, the Team Edition’s basic capabilities are sufficient for most small-to-medium teams.

Troubleshooting

  • Logs: If you encounter any issues, you can check the logs using: sudo docker logs mattermost
  • Updating Mattermost: To update Mattermost to the latest version, stop the container, pull the latest image, and restart the service: sudo docker-compose down sudo docker pull mattermost/mattermost-team-edition:latest sudo docker-compose up -d

Final words

You have successfully set up Mattermost on Debian 12 using Docker with an external PostgreSQL database and host network mode.

This setup is suitable for production environments and provides better scalability and reliability compared to SQLite. For additional scalability, consider adding external database backup solutions and reverse proxy configurations.

Leave A Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.