Skip to content

Instantly share code, notes, and snippets.

@kaustubhn
Created February 20, 2026 03:56
Show Gist options
  • Select an option

  • Save kaustubhn/704691ac7ef2a80f4a62c62c9c610eb6 to your computer and use it in GitHub Desktop.

Select an option

Save kaustubhn/704691ac7ef2a80f4a62c62c9c610eb6 to your computer and use it in GitHub Desktop.
Mautic 7 on Coolify with Docker Compose

Mautic 7 on Coolify — Docker Compose Setup

docker-compose.yml

services:

  db:
    image: mariadb:11.4
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
      MYSQL_DATABASE: ${MYSQL_DATABASE:-mautic}
      MYSQL_USER: ${MYSQL_USER:-mautic}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD}
    volumes:
      - mautic_db:/var/lib/mysql
    command: >
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_unicode_ci
      --innodb-buffer-pool-size=256M
    healthcheck:
      test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
      interval: 10s
      timeout: 5s
      retries: 10
      start_period: 30s
    networks:
      - mautic_internal

  mautic_web:
    image: mautic/mautic:7-apache
    restart: unless-stopped
    environment:
      MAUTIC_DB_HOST: db
      MAUTIC_DB_PORT: 3306
      MAUTIC_DB_DATABASE: ${MYSQL_DATABASE:-mautic}
      MAUTIC_DB_USER: ${MYSQL_USER:-mautic}
      MAUTIC_DB_PASSWORD: ${MYSQL_PASSWORD}
      MAUTIC_TRUSTED_PROXIES: '["0.0.0.0/0"]'
      DOCKER_MAUTIC_ROLE: mautic_web
      DOCKER_MAUTIC_RUN_MIGRATIONS: "true"
      PHP_INI_DATE_TIMEZONE: ${TZ:-UTC}
      PHP_MEMORY_LIMIT: ${PHP_MEMORY_LIMIT:-512M}
    volumes:
      - mautic_config:/var/www/html/config
      - mautic_logs:/var/www/html/var/logs
      - mautic_media:/var/www/html/docroot/media
      - mautic_themes:/var/www/html/themes
    depends_on:
      db:
        condition: service_healthy
    networks:
      - mautic_internal
      - mautic_external

  mautic_cron:
    image: mautic/mautic:7-apache
    restart: unless-stopped
    environment:
      MAUTIC_DB_HOST: db
      MAUTIC_DB_PORT: 3306
      MAUTIC_DB_DATABASE: ${MYSQL_DATABASE:-mautic}
      MAUTIC_DB_USER: ${MYSQL_USER:-mautic}
      MAUTIC_DB_PASSWORD: ${MYSQL_PASSWORD}
      DOCKER_MAUTIC_ROLE: mautic_cron
      PHP_INI_DATE_TIMEZONE: ${TZ:-UTC}
      PHP_MEMORY_LIMIT: ${PHP_MEMORY_LIMIT:-512M}
    volumes:
      - mautic_config:/var/www/html/config
      - mautic_logs:/var/www/html/var/logs
      - mautic_media:/var/www/html/docroot/media
      - mautic_themes:/var/www/html/themes
    depends_on:
      db:
        condition: service_healthy
      mautic_web:
        condition: service_started
    networks:
      - mautic_internal

  mautic_worker:
    image: mautic/mautic:7-apache
    restart: unless-stopped
    environment:
      MAUTIC_DB_HOST: db
      MAUTIC_DB_PORT: 3306
      MAUTIC_DB_DATABASE: ${MYSQL_DATABASE:-mautic}
      MAUTIC_DB_USER: ${MYSQL_USER:-mautic}
      MAUTIC_DB_PASSWORD: ${MYSQL_PASSWORD}
      DOCKER_MAUTIC_ROLE: mautic_worker
      DOCKER_MAUTIC_WORKERS_CONSUME_EMAIL: 2
      DOCKER_MAUTIC_WORKERS_CONSUME_HIT: 2
      DOCKER_MAUTIC_WORKERS_CONSUME_FAILED: 1
      PHP_INI_DATE_TIMEZONE: ${TZ:-UTC}
      PHP_MEMORY_LIMIT: ${PHP_MEMORY_LIMIT:-512M}
    volumes:
      - mautic_config:/var/www/html/config
      - mautic_logs:/var/www/html/var/logs
      - mautic_media:/var/www/html/docroot/media
      - mautic_themes:/var/www/html/themes
    depends_on:
      db:
        condition: service_healthy
      mautic_web:
        condition: service_started
    networks:
      - mautic_internal

volumes:
  mautic_db:
  mautic_config:
  mautic_logs:
  mautic_media:
  mautic_themes:

networks:
  mautic_internal:
    internal: true
  mautic_external:
    external: false

Environment Variables

Set these in Coolify's Environment Variables panel (mark passwords as sensitive):

MYSQL_ROOT_PASSWORD=your_root_password
MYSQL_DATABASE=mautic
MYSQL_USER=mautic
MYSQL_PASSWORD=your_mautic_password
TZ=UTC
PHP_MEMORY_LIMIT=512M

Coolify Configuration

  • Domain: https://yourdomain.com — no port suffix, no :80
  • Ports: Do not expose any ports on mautic_web — Traefik handles routing internally
  • MAUTIC_TRUSTED_PROXIES must be set as a JSON array: ["0.0.0.0/0"]

Installation

After all containers are running and healthy, run the installer:

# Find your web container name
docker ps --format "{{.Names}}" | grep mautic_web

# Run the installer (use single quotes around password to avoid bash special char issues)
docker exec --user www-data --workdir /var/www/html <container_name> \
  php bin/console mautic:install https://yourdomain.com \
  --admin_email="admin@yourdomain.com" \
  --admin_password='YourPassword' \
  --admin_firstname="First" \
  --admin_lastname="Last"

Expected output:

Mautic Install
==============
0 - Checking installation requirements...
1 - Creating database...
1.1 - Creating schema...
1.2 - Loading fixtures...
2 - Creating admin user...
3 - Final steps...
================
Install complete
================

Gotchas & Fixes

Problem Fix
bash: !: event not found Use single quotes around password: --admin_password='Pass!@123'
Invalid JSON in env var MAUTIC_TRUSTED_PROXIES Set value as ["0.0.0.0/0"] not 0.0.0.0/0
504 Gateway Timeout Remove :80 from domain in Coolify UI
"The site is currently offline" Run the install command — installer hasn't been run yet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment