Sign inSign up

guerchele/mautic

By guerchele

Updated 3 months ago

A production-ready, highly optimized Docker setup for **Mautic 7**.

Image
Web servers
0

10K+

guerchele/mautic repository overview

Mautic 7 Production Docker Setup

This repository contains a production-ready, highly optimized Docker setup for Mautic 7, built directly from the official Mautic pre-compiled release ZIP archives.

Unlike older Mautic Docker setups, this architecture conforms to Mautic 7's container-native guidelines:

  • No in-app updates: Eliminates timeouts and broken states. All updates are handled by upgrading the container image.
  • Decoupled services: Separate containers handle web traffic, cron schedules, and Symfony Messenger workers to scale independently.
  • Optimized builds: Built directly from production archives, omitting heavy development libraries and package managers (e.g., Composer, Git) from the final runtime image.

Prerequisites

  1. Docker & Docker Compose installed.
  2. Database Engine: Mautic 7 requires a minimum of MySQL 8.4+ or MariaDB 10.11+.

Quick Start (Single Container docker run)

To run Mautic quickly for testing purposes against an existing external database:

docker run -d \
  --name mautic_web \
  -p 8880:80 \
  -e MAUTIC_DB_HOST=your-db-host \
  -e MAUTIC_DB_USER=your-db-user \
  -e MAUTIC_DB_PASSWORD=your-db-password \
  -e MAUTIC_DB_DATABASE=mautic \
  guerchele/mautic:7.1.2

Production Deployment (docker compose)

In production environments, Mautic 7 benefits heavily from separation of concerns. The included docker-compose.yml spins up:

  1. db: MySQL 8.4 database.
  2. mautic_web: The web service running Apache.
  3. mautic_cron: Runs the crontab daemon (cron -f) to execute scheduled tasks (e.g., segment updates, campaign triggers) without blocking the web request path.
  4. mautic_worker: Executes Symfony Messenger queue consumers (bin/console messenger:consume) to process emails and page tracking hits asynchronously in real time.
docker-compose.yml
services:
  db:
    image: 'mysql:8.4'
    environment:
      - 'MYSQL_ROOT_PASSWORD=${SERVICE_PASSWORD_64_MYSQLROOT}'
      - 'MYSQL_DATABASE=${MYSQL_DATABASE:-mautic}'
      - 'MYSQL_USER=${SERVICE_USER_MYSQL}'
      - 'MYSQL_PASSWORD=${SERVICE_PASSWORD_64_MYSQL}'
    volumes:
      - 'mysql-data:/var/lib/mysql'
    healthcheck:
      test: 'mysqladmin ping --silent --user=$${SERVICE_USER_MYSQL} --password=$${SERVICE_PASSWORD_64_MYSQL}'
      start_period: 30s
      interval: 10s
      timeout: 5s
      retries: 5

  mautic_web:
    image: 'guerchele/mautic:${MAUTIC_VERSION:-7.1.2}'
    ports:
      - '8880:80'
    volumes:
      - 'mautic_config:/var/www/html/app/config'
      - 'mautic_logs:/var/www/html/var/logs'
      - 'mautic_media_files:/var/www/html/media/files'
      - 'mautic_media_images:/var/www/html/media/images'
      - 'mautic_plugins:/var/www/html/plugins'
    environment:
      - SERVICE_FQDN_MAUTIC_80
      - 'MAUTIC_DB_HOST=${MYSQL_HOST:-db}'
      - 'MAUTIC_DB_PORT=${MYSQL_PORT:-3306}'
      - 'MAUTIC_DB_DATABASE=${MYSQL_DATABASE:-mautic}'
      - 'MAUTIC_DB_USER=${SERVICE_USER_MYSQL}'
      - 'MAUTIC_DB_PASSWORD=${SERVICE_PASSWORD_64_MYSQL}'
    depends_on:
      db:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost"]
      interval: 15s
      timeout: 10s
      retries: 15

  mautic_cron:
    image: 'guerchele/mautic:${MAUTIC_VERSION:-7.1.2}'
    volumes:
      - 'mautic_config:/var/www/html/app/config'
      - 'mautic_logs:/var/www/html/var/logs'
      - 'mautic_media_files:/var/www/html/media/files'
      - 'mautic_media_images:/var/www/html/media/images'
      - 'mautic_plugins:/var/www/html/plugins'
    environment:
      - 'MAUTIC_DB_HOST=${MYSQL_HOST:-db}'
      - 'MAUTIC_DB_PORT=${MYSQL_PORT:-3306}'
      - 'MAUTIC_DB_DATABASE=${MYSQL_DATABASE:-mautic}'
      - 'MAUTIC_DB_USER=${SERVICE_USER_MYSQL}'
      - 'MAUTIC_DB_PASSWORD=${SERVICE_PASSWORD_64_MYSQL}'
    command: ["cron", "-f"]
    depends_on:
      mautic_web:
        condition: service_healthy

  mautic_worker:
    image: 'guerchele/mautic:${MAUTIC_VERSION:-7.1.2}'
    volumes:
      - 'mautic_config:/var/www/html/app/config'
      - 'mautic_logs:/var/www/html/var/logs'
      - 'mautic_media_files:/var/www/html/media/files'
      - 'mautic_media_images:/var/www/html/media/images'
      - 'mautic_plugins:/var/www/html/plugins'
    environment:
      - 'MAUTIC_DB_HOST=${MYSQL_HOST:-db}'
      - 'MAUTIC_DB_PORT=${MYSQL_PORT:-3306}'
      - 'MAUTIC_DB_DATABASE=${MYSQL_DATABASE:-mautic}'
      - 'MAUTIC_DB_USER=${SERVICE_USER_MYSQL}'
      - 'MAUTIC_DB_PASSWORD=${SERVICE_PASSWORD_64_MYSQL}'
    command: ["php", "bin/console", "messenger:consume", "email", "hit", "--time-limit=3600"]
    depends_on:
      mautic_web:
        condition: service_healthy

volumes:
  mysql-data: null
  mautic_config: null
  mautic_logs: null
  mautic_media_files: null
  mautic_media_images: null
  mautic_plugins: null
Starting the Stack
# Set version if you wish to override the default (7.1.2)
export MAUTIC_VERSION=7.1.2

# Start all services
docker compose up -d

Environment Variables

VariableDescriptionDefault
MAUTIC_DB_HOSTDatabase host addressdb
MAUTIC_DB_PORTDatabase connection port3306
MAUTIC_DB_DATABASEDatabase namemautic
MAUTIC_DB_USERDatabase user name
MAUTIC_DB_PASSWORDDatabase user password

Volume Mappings

Ensure you map volumes correctly to avoid data loss. Mautic 7 uses standard PHP structure:

  • mautic_config:/var/www/html/app/config - Mautic configuration settings (credentials, custom settings).
  • mautic_logs:/var/www/html/var/logs - Log files.
  • mautic_media_files:/var/www/html/media/files - Uploaded assets and files.
  • mautic_media_images:/var/www/html/media/images - Image files.
  • mautic_plugins:/var/www/html/plugins - Custom or premium Mautic plugins.

Note: Named volumes on /var/www/html/vendor or /var/www/html/bin should NOT be mapped as volumes since Mautic 7 comes with precompiled dependencies inside the image.

Tag summary

Content type

Image

Digest

sha256:e0d33f381

Size

402.1 MB

Last updated

3 months ago

docker pull guerchele/mautic