목. 7월 24th, 2025

🌟 Introduction

Mattermost is an open source enterprise messenger and alternative to Slack. With Docker Compose, you can build a production environment with MySQL/PostgreSQL DB and Nginx proxy in 5 minutes! In this guide:

  • How to write docker-compose.yml.
  • Utilizing the .env file for setting environment variables
  • Tips for enforcing HTTPS step by step.

—.

⚙️ 1. Prerequisites

  • Install Docker & Docker Compose**.
    # Ubuntu example
    sudo apt update && sudo apt install docker.io docker-compose
  • Prepare a domain (optional): Required when enforcing HTTPS
  • Check for port conflicts: Make sure ports 80, 443, 8065 are enabled

—.

📂 2. Create project structure

mkdir mattermost-docker && cd mattermost-docker
mkdir -p ./volumes/{app,db,web/cert} # Permanent data storage directory
touch docker-compose.yml .env # Create core files

—]

🐋 3. Write docker-compose.yml

version: '3.7'

services:
  db:
    image: mysql:8.0
    environment:
      mysql_root_password: ${db_root_password}
      mysql_database: ${db_name}
      mysql_user: ${db_user}
      mysql_password: ${db_password}
    volumes:
      - ./volumes/db:/var/lib/mysql # Preserve DB data
    networks:
      - mm-network

  app:
    image: mattermost/mattermost-team-edition
    depends_on:
      - db
    environment:
      MM_SQLSETTINGS_DRIVERNAME: mysql
      MM_SQLSETTINGS_DATASOURCE: "${DB_USER}:${DB_PASSWORD}@tcp(db:3306)/${DB_NAME}?charset=utf8mb4"
      mm_servicesettings_siteurl: ${site_url}
    volumes:
      - ./volumes/app:/mattermost/data # Store uploaded files, etc.
    networks:
      - mm-network

  web:
    image: nginx:alpine
    ports:
      - "80:80"
      - "443:443" # When applying HTTPS
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
      - ./volumes/web/cert:/etc/letsencrypt # Save the certificate
    depends_on:
      - App.
    networks:
      - mm-network

networks:
  mm-network:
    driver: bridge

🔍 Description of key settings.

  • Dependency management**: Ensure DB → App → Web execution order with depends_on.
  • Network: Create mm-network bridges for communication between services
  • Volume mount**: Preserve data when recreating containers

—.

⚡ 4. Set up the .env file

# DB configuration
DB_ROOT_PASSWORD=SuperSecretRootPass!123
DB_NAME=mattermost
DB_USER=mm_user
DB_PASSWORD=Strong!UserPass456

# Set up Mattermost
SITE_URL=https://chat.yourdomain.com # HTTPS required!

🚨 Precautions

  1. create a password with English case + numbers + special characters combination
  2. SITE_URL must start with HTTPS (when SSL is applied)
  3. set .env file permission to 600 in the actual production environment

—]

🔒 5. Configure Nginx (HTTPS)

Create nginx.conf file:

events {}
http {
  server {
    listen 80;
    server_name chat.yourdomain.com;
    return 301 https://$host$request_uri; # force HTTP → HTTPS transition
  }

  server {
    listen 443 ssl;
    server_name chat.yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/chat.yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/chat.yourdomain.com/privkey.pem;

    location / {
      proxy_pass http://app:8065;
      proxy_set_header X-Forwarded-For $remote_addr;
    }
  }
}

📜 Issue a certificate (Let’s Encrypt)

docker run -it --rm --name certbot \
  -v "./volumes/web/cert:/etc/letsencrypt" \
  -p 80:80 \
  certbot/certbot certonly --standalone -d chat.yourdomain.com

—]

🚀 6. Run and verify

docker-compose up -d # Run in the background
docker-compose logs -f app # Monitor real-time logs
  • Test connectivity: https://chat.yourdomain.com
  • Initial administrator account: sysadmin / check console logs for password

—]

🛠 7. Additional setup tips

🔄 Configure backups

# backup DB
docker exec -i mattermost-docker_db_1 mysqldump -u root -p${DB_ROOT_PASSWORD} ${DB_NAME} > backup.sql

# backup the file store
tar czvf mattermost-data.tar.gz ./volumes/app

⚙️ Extend environment variables

Can be added to .env:

# Set up email notifications
MM_EMAILSETTINGS_SMTPSERVER=smtp.gmail.com
mm_emailsettings_smtport=587
MM_EMAILSETTINGS_CONNECTION_SECURITY=starttls
MM_EMAILSETTINGS_FEEDBACKNAME=MattermostBot

—.

🎯 Conclusion

Once you configure Mattermost with Docker Compose:
Fast to deploy (done in 5 minutes) Easy to upgrade (docker-compose pull && docker-compose up -d) Scalable (DB/App can be deployed separately when users grow) Security ↑ + $200k+/year cost savings with data self-hosting compared to Slack!

> 💬 Official documentation in case of issues:
> Mattermost Docker Guide

After the initial setup, invite team members → create channels → utilize slash commands to increase productivity! 🚀 D

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다