In today’s digital marketing landscape, having a robust marketing automation platform is essential for businesses of all sizes. While there are many proprietary solutions available, Mautic stands out as a powerful open-source alternative that gives you complete control over your marketing stack. In this guide, we’ll explore how to set up a self-hosted Mautic instance using Docker, providing you with a flexible, scalable, and cost-effective marketing automation solution.
What is Mautic?
Mautic is a fully-featured, open-source marketing automation platform founded in 2014. Unlike proprietary solutions that lock you into their ecosystems, Mautic provides all the tools you need to create sophisticated marketing campaigns while maintaining full control over your data and infrastructure.
Key Features of Mautic
- Multi-Channel Campaign Management: Create sophisticated automated workflows across email, SMS, web notifications, and more
- Contact Management: Comprehensive contact profiles with detailed activity tracking
- Email Marketing: Built-in email builder with templates, personalization, and A/B testing
- Website Tracking: Monitor visitor behavior similar to Google Analytics, but with the ability to tie anonymous visitors to known contacts
- Landing Pages & Forms: Create and manage custom landing pages and forms to capture leads
- Segmentation: Powerful filtering options to create targeted audience segments
- Lead Scoring & Stages: Track lead development with a point system and custom stages
- Dynamic Web Content: Personalize website content based on visitor data
- Reporting & Analytics: In-depth reporting on campaign performance and contact engagement
Mautic is used by over 250,000 companies worldwide, including enterprise organizations like Airbus and Konica Minolta.
Why Self-Host Mautic?
While Mautic does offer a free cloud-hosted version, self-hosting provides several significant advantages:
- No Limitations: The cloud version restricts you to 5,000 contacts, 1,000 emails per day, and a single admin user. Self-hosting removes these limits entirely.
- Complete Data Control: Keep sensitive customer data within your own infrastructure, making GDPR and other privacy compliance simpler.
- Customization Freedom: Modify any aspect of the platform to suit your specific business needs.
- Cost-Effectiveness: For larger contact databases, self-hosting can be significantly more cost-effective than SaaS alternatives like HubSpot or Infusionsoft.
- Integration Flexibility: Connect Mautic with any other system in your technology stack.
Why Use Docker for Mautic Installation?
Docker provides several advantages when deploying Mautic:
- Simplified Installation: Docker abstracts away many of the complexities of traditional installations.
- Consistent Environments: Ensure your development, testing, and production environments are identical.
- Easy Updates: Update Mautic and its dependencies with minimal downtime and effort.
- Isolation: Keep Mautic separate from other applications running on your server.
- Scalability: Easily scale resources as your needs grow.
Prerequisites
Before we begin, make sure you have:
- A server running Linux (Ubuntu is recommended and used in this guide)
- Docker and Docker Compose installed
- Basic command line knowledge
- A domain or subdomain for your Mautic instance (optional but recommended)
- An SMTP service for sending emails (essential for production use)
Step-by-Step Docker Installation
Step 1: Install Docker and Docker Compose
If you don’t already have Docker and Docker Compose installed, here’s how to set them up on Ubuntu:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# Update your package list sudo apt update # Install required packages sudo apt install apt-transport-https ca-certificates curl software-properties-common # Add Docker's official GPG key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - # Add the Docker repository sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" # Update package database with Docker packages sudo apt update # Install Docker sudo apt install docker-ce # Install Docker Compose sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose # Verify installations docker --version docker-compose --version # Enable Docker to start on boot sudo systemctl enable docker |
Step 2: Create a Docker Compose Configuration
Create a new directory for your Mautic installation and set up your Docker Compose file:
1 2 3 4 5 6 7 8 |
# Create a directory for your Mautic installation mkdir mautic cd mautic # Create the docker-compose.yml file nano docker-compose.yml |
Copy and paste the following configuration into the file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
version: '2' services: mauticdb: image: percona/percona-server:5.7 container_name: mauticdb volumes: - mysql_data:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD=YourSecurePassword # Change this to a secure password command: --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci networks: - mautic-net mautic: image: mautic/mautic:v4 # Use v4 for the latest stable version container_name: mautic links: - mauticdb:mysql depends_on: - mauticdb ports: - "8080:80" # Map to port 8080 - change this if needed volumes: - mautic_data:/var/www/html environment: - MAUTIC_DB_HOST=mauticdb - MYSQL_PORT_3306_TCP=3306 - MAUTIC_DB_USER=root - MAUTIC_DB_PASSWORD=YourSecurePassword # Use the same password as above - 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 |
Important Configuration Notes:
- Change
YourSecurePassword
to a strong, unique password - The configuration uses Mautic v4, which is recommended for new installations
- By default, Mautic will be accessible on port 8080
MAUTIC_RUN_CRON_JOBS=true
enables built-in cron jobs for automated tasks
Save the file and exit the editor.
You can find the official Mautic Docker image on Docker Hub where you can also review additional tags and version options.
Step 3: Start the Mautic Containers
Run the following command to start your Mautic instance:
1 2 3 |
docker-compose up -d |
The -d
flag runs the containers in detached mode, allowing them to run in the background. Docker will pull the necessary images and start the containers.
You can check if the containers are running correctly by using:
1 2 3 |
docker-compose ps |
Step 4: Access Mautic
Once the containers are running, you can access your Mautic installation by navigating to:
1 2 3 |
http://your-server-ip:8080 |
Or if you’re running it locally:
1 2 3 |
http://localhost:8080 |
Step 5: Set Up Mautic
You’ll now see the Mautic installation wizard. Follow these steps:
- System Check: Mautic will check if your environment meets all requirements. If there are any issues, resolve them before continuing.
- Database Configuration: The database settings should be pre-filled based on your Docker Compose configuration:
- Database Host: mauticdb
- Database User: root
- Database Password: YourSecurePassword (the one you set in docker-compose.yml)
- Database Name: mautic
- Database Port: 3306
- Admin User Setup: Create your administrator account by entering:
- Username
- Password
- First and Last Name
- Email Address (used for password resets and as default sender)
- Email Configuration: Set up your email sending method:
- Choose an email transport method (SMTP is recommended for production)
- Enter your SMTP server details (host, port, username, password)
- Configure email handling (immediate or queue)
Setting Up a Reverse Proxy (Optional)
For production environments, it’s recommended to set up a reverse proxy to:
- Enable HTTPS with SSL certificates
- Use your domain name instead of an IP:port combination
- Provide an additional security layer
Learn more about reverse proxies in the Docker documentation.
Using Apache as a Reverse Proxy
If you’re using Apache, follow these steps:
1. Create a new virtual host configuration:
1 2 3 |
sudo nano /etc/apache2/sites-available/mautic.conf |
2. Add the following configuration:
1 2 3 4 5 6 7 8 9 10 11 12 |
<virtualhost *:80=""> ServerName mautic.yourdomain.com ProxyPreserveHost On ProxyPass "/" "http://127.0.0.1:8080/" ProxyPassReverse "/" "http://127.0.0.1:8080/" ErrorLog ${APACHE_LOG_DIR}/mautic_error.log CustomLog ${APACHE_LOG_DIR}/mautic_access.log combined </virtualhost> |
3. Enable the required Apache modules:
1 2 3 4 5 6 |
sudo a2enmod proxy sudo a2enmod proxy_http sudo a2enmod proxy_balancer sudo a2enmod lbmethod_byrequests |
4. Enable the site and restart Apache:
1 2 3 4 |
sudo a2ensite mautic.conf sudo systemctl restart apache2 |
5. Consider adding SSL with Let’s Encrypt:
1 2 3 4 |
sudo apt install certbot python3-certbot-apache sudo certbot --apache -d mautic.yourdomain.com |
Post-Installation Configuration
After installation, there are several important configurations to optimize your Mautic installation:
1. Email Configuration
For production use, it’s essential to configure a reliable email delivery service. While you can use your server’s mail system, it’s recommended to use a specialized email service provider like:
Most providers offer a free tier for low-volume sending, with paid plans for higher volumes.
To configure your email provider:
- Go to Settings > Configuration > Email Settings
- Select your Mailer Transport
- Enter the required credentials
- Test your configuration with the “Send Test Email” button
2. Cron Jobs
While the Docker setup includes basic cron job handling, for optimal performance you might want to configure external cron jobs. Create a cron job that runs every 5 minutes with the following command:
1 2 3 |
*/5 * * * * docker exec mautic php /var/www/html/bin/console mautic:segments:update && docker exec mautic php /var/www/html/bin/console mautic:campaigns:update && docker exec mautic php /var/www/html/bin/console mautic:campaigns:trigger |
3. Performance Optimization
For larger installations, consider these performance optimizations:
1. Adjust PHP memory limits in your docker-compose.yml file:
1 2 3 4 |
environment: - PHP_MEMORY_LIMIT=512M |
2. Configure queue processing for emails instead of immediate sending:
- Go to Settings > Configuration > Email Settings
- Set “Email handling” to “Queue email”
3. Consider separate database optimizations:
- Add an external Redis container for cache storage
- Configure MySQL/MariaDB with optimized settings
Common Issues and Troubleshooting
SMTP Configuration Issues
If you’re experiencing problems sending emails:
- Verify your SMTP credentials
- Check if your SMTP provider has sending limits
- Ensure your sender email domain matches your authenticated domain
- Test with different ports (587, 465, 25)
Database Connection Errors
If Mautic can’t connect to the database:
- Verify the database credentials in your docker-compose.yml
- Check if the database container is running
- Try restarting both containers
Performance Problems
If Mautic is slow or unresponsive:
- Increase the resources allocated to your Docker containers
- Optimize your database with proper indexing
- Consider implementing a caching solution
- Run campaigns and segment updates through cron jobs
Updating Mautic
To update your Mautic installation when a new version is released:
1. Back up your data:
1 2 3 |
docker-compose exec mauticdb mysqldump -u root -p mautic > mautic_backup.sql |
2. Update the Mautic image version in your docker-compose.yml:
1 2 3 |
image: mautic/mautic:v4.x.x # Replace with the new version |
3. Pull the new image and restart:
1 2 3 4 5 |
docker-compose pull docker-compose down docker-compose up -d |
FAQ
Basics of Marketing Automation
What is a marketing automation platform?
When should I start implementing a marketing automation platform?
How is marketing automation different from email marketing?
Core Features and Capabilities
What are the essential features of a marketing automation platform?
How does lead scoring work in marketing automation?
Can marketing automation platforms help with social media marketing?
What types of reports and analytics do marketing automation platforms provide?
Implementation and Integration
How difficult is it to implement a marketing automation platform?
How do marketing automation platforms integrate with CRM systems?
What technical skills are needed to use a marketing automation platform?
Costs and ROI
How much does a marketing automation platform typically cost?
How do I measure the ROI of a marketing automation platform?
Compliance and Privacy
How do marketing automation platforms help with GDPR compliance?
What privacy considerations should I keep in mind when using marketing automation?
Latest Trends (2024-2025)
How is AI changing marketing automation platforms?
What are the emerging trends in marketing automation for 2024-2025?
How are marketing automation platforms handling cookieless tracking?
What role does conversational marketing play in modern automation platforms?
Technical Implementation Example
What does a basic marketing automation workflow look like in code?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
// Example Lead Nurturing Workflow // Define trigger event ON event "Form Submission" WHERE form_id = "lead_magnet_download": // Add to segment and set properties ADD contact TO segment "Lead Magnet Readers" SET contact.lead_score += 10 SET contact.interest = "{{form.topic}}" // Send immediate email SEND email "thank_you_template" TO contact // Wait period WAIT 3 days // Conditional path based on behavior IF contact.email_opened = true: SEND email "follow_up_engaged" TO contact SET contact.lead_score += 5 ELSE: SEND email "follow_up_reminder" TO contact // Wait period WAIT 4 days // Check engagement level IF contact.lead_score >= 20: SEND notification TO sales_team ADD contact TO crm.pipeline "Qualified Leads" ELSE: ADD contact TO workflow "Long Term Nurture" |
Thoughts
Self-hosting Mautic with Docker provides a powerful, flexible, and cost-effective marketing automation solution. You gain complete control over your data, unlimited contacts and emails, and the ability to customize the platform to your specific needs.
While initial setup requires some technical knowledge, the long-term benefits for privacy, customization, and cost-effectiveness make it a compelling option for businesses of all sizes.
Further Resources
- Official Mautic Documentation
- Mautic GitHub Repository
- Mautic Community Forums
- Mautic Community Portal
- Docker Documentation
- Docker Compose Documentation
- Mautic Docker Image
- Mautic Knowledge Base