Installing Mautic Email Marketing Tool Using Docker: A Simplified Guide

Mautic, an open-source marketing automation tool, can be installed in various ways, but this guide focuses on using Docker for its simplicity and efficiency. Docker allows for easy deployment and management of Mautic, making it an ideal choice for users looking for a straightforward installation process. While other methods exist, this guide emphasizes the Docker approach as it streamlines the setup and configuration of Mautic.


Installing Mautic with Docker

Pulling the Docker Image

To begin the installation process, the first step is to pull the latest stable Mautic image from Docker Hub. Run the following command in your terminal.

docker pull mautic/mautic:latest

Running Basic Containers

Before running Mautic, it's necessary to set up a MySQL server. Create a Docker volume for MySQL data:

docker volume create mysql_data

Next, run the MySQL container (using Percona as an example):

docker run --name percona -d \
    -p 3306:3306 \
    -e MYSQL_ROOT_PASSWORD=mypassword \
    -v mysql_data:/var/lib/mysql \
    percona/percona-server:5.7 \
    --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
Now, create a Docker volume for Mautic data:
docker volume create mautic_data

Finally, run the Mautic container:

docker run --name mautic -d \
    --restart=always \
    -e MAUTIC_DB_HOST=127.0.0.1 \
    -e MAUTIC_DB_USER=root \
    -e MAUTIC_DB_PASSWORD=mypassword \
    -e MAUTIC_DB_NAME=mautic \
    -e MAUTIC_RUN_CRON_JOBS=true \
    -e MAUTIC_TRUSTED_PROXIES=0.0.0.0/0 \
    -p 8080:80 \
    -v mautic_data:/var/www/html \
    mautic/mautic:latest

This will launch a basic MySQL service within Mautic, accessible at http://localhost:8080.


Customizing Mautic Container

Database Options

Mautic container provides various environment variables for database configuration:

If using an external database, provide the hostname, port, password, and username accordingly.

Mautic Options

Several environment variables control Mautic's behavior:

Enable/Disable Features

PHP Options

Persistent Data Volumes

Mautic stores data at /var/www/html, requiring a volume for persistence.

Mautic Versioning

Specify the Mautic version and SHA1 hash using the following environment variables:


Accessing the Mautic Instance

After successfully setting up Mautic, access it at http://localhost:8080 or http://host-ip:8080 in a web browser.


Using Docker-Compose

For a more organized setup, use Docker Compose. Here's an example docker-compose.yml file:

version: '2'

services:

  mauticdb:
    image: percona/percona-server:5.7
    container_name: mauticdb
    volumes:
      - mysql_data:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=mysecret
    command:
      --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci
    networks:
      - mautic-net

  mautic:
    image: mautic/mautic:latest
    container_name: mautic
    links:
      - mauticdb:mysql
    depends_on:
      - mauticdb
    ports:
      - 8080:80
    volumes:
      - mautic_data:/var/www/html
    environment:
      - MAUTIC_DB_HOST=mauticdb
      - MYSQL_PORT_3306_TCP=3306
      - MAUTIC_DB_USER=root
      - MAUTIC_DB_PASSWORD=mysecret
      - MAUTIC_DB_NAME=mautic
      - MAUTIC_RUN_CRON_JOBS=true
    networks:
      - mautic-net

volumes:
  mysql_data:
    driver: local
  mautic_data:
    driver: local
networks:
  mautic-net:
    driver: bridge
Run docker-compose up, wait for initialization, and access Mautic at http://localhost:8080 or http://host-ip:8080.

Conclusion

By opting for Docker as the installation method for Mautic, users benefit from a simplified and efficient process. This guide covers the basics of pulling the image, running containers, customization options, and utilizing Docker Compose for a more organized deployment. Access Mautic through the provided URLs and leverage its powerful marketing automation features with ease.


Revision #1
Created 28 January 2024 18:40:58 by Admin
Updated 11 February 2024 19:37:48 by Admin