Autoize has launched a public Docker repository, and has committed to maintaining it with an image containing the latest version of Mautic, currently version 2.10.1. Visit us on the Docker Hub at autoize/mautic to get your copy.
September 18, 2017 – Autoize/Mautic Docker image has been updated to 2.10.1. If you are using a previous version of our image, you don’t need to pull this new one. Simply update using the notification in the Mautic dashboard.
September 10, 2017 – Autoize/Mautic Docker image has been updated to 2.10.0.
September 9, 2017 – Autoize/Mautic Docker image has been updated to 2.9.2.
April 26, 2017 – Autoize/Mautic Docker image has been updated to 2.8.0.
March 15, 2017 – Autoize/Mautic Docker image has been updated to 2.7.1.
March 6, 2017 – Autoize/Mautic Docker image has been updated to 2.7.0
February 16, 2017 – Autoize/Mautic Docker image has been updated to 2.6.1.
February 9, 2017 – Autoize/Mautic Docker image has been updated to 2.6.0.
January 5, 2017 – Autoize/Mautic Docker image has been updated to 2.5.1.
December 13, 2016 – Autoize/Mautic Docker image has been updated to 2.4.0.
Why Run Mautic Inside a Docker Container
Docker is a new technology letting developers “build once, run anywhere”, deploying their code as a container containing all of the required dependencies so it’s guaranteed to work on another machine. It is an improved implementation of Linux Containers (LXC) but is very much the same concept. Docker containers share the Linux kernel of the host machine they run on, making them a light-weight virtual machine (VM) of sorts. They bridge the gap between processes running directly on a host, and full-on VMs which require more system resources.
Docker containers are a user-friendly way to deploy open source applications, including the Mautic marketing automation platform. In this tutorial, you will learn how to run Mautic as a Docker container on a DigitalOcean VPS. You can follow the steps on any server that has the Docker Engine installed, but if you sign up with this link you can receive $10 in free hosting credit from DigitalOcean. Another solid option for VPS hosting includes Linode, which we recently named the best Mautic VPS hosting service.
Benefits of using Docker include faster deployment, migration and for advanced users, the ability to load balance a large Mautic installation across multiple servers. Hosted services like the Mautic Cloud, rely on containerization technology to rapidly provision and isolate new instances of Mautic for their customers.
Mautic has an official Docker image, but it has not been updated to the latest version. Therefore we will use the autoize/mautic repository on the Docker Hub that has been updated to install the latest version of Mautic, version 2.10.0. If you have the know-how, you may also build your own Docker image from the Dockerfile hosted at GitHub.
- Launch a Droplet with the latest Docker 1-Click Image. The $5/month Droplet with 512 MB RAM is sufficient to run a small Mautic instance. You can increase the CPU and RAM of your Droplet at any time.
- Point your subdomain or domain name at the Droplet using the Networking tab in DigitalOcean. You will also need to create an A record pointing to the IP address of your Droplet at your DNS provider, who is usually your domain registrar or a third-party service such as DynDNS.
- SSH in and pull the following images from the Docker Hub:
docker pull mysql:latest
docker pull autoize/mautic:latest
- Set up a swap file of at least 4 GB. This prevents your MySQL container from crashing due to “out of memory” errors, which was a problem we frequently encountered.
- Build and start your MySQL container. You need to specify a root password for the MYSQL_ROOT_PASSWORD environment variable, which will be used for installation later. Make it secure with a password generator.
docker run --name mauticdb -e MYSQL_ROOT_PASSWORD=example -e MYSQL_DATABASE=mautic -d --restart always mysql:latest
docker start mauticdb
- Build and start your Mautic container. This command links your Mautic container to the MySQL container you created previously, allowing Mautic to communicate with the database server. Also, it maps port 80 to the Apache server running inside the container – making your Mautic instance accessible from a public IP address.
docker run --name mautic --link mauticdb:mysql -e MAUTIC_DB_PASSWORD=example -p 80:80 -d --restart always autoize/mautic:latest
docker start mautic
- Visit your subdomain or domain to install Mautic. If you see the “Mautic is ready to install” message, you are good to go. The database connection information for Step 2 is as follows (Everything is default except for your MySQL root password):
- Database Host: mysql
- Database Port: 3306
- Database User: root
- Database Password: Your MySQL Root Password
If you want to check what Docker containers are created, started or stopped on your server at any time, use the following command:
docker ps -a. To run Mautic on Docker, you should have a MySQL container and Mautic container started at all times.
Running Mautic as a Docker container is a time-saving shortcut compared to configuring Apache, MySQL, PHP and uploading the files yourself. If you need to bring up a Mautic instance in a flash, this is the way to do it.
Docker containers are also easy to backup. You can use the docker save command to easily export both your Mautic files and MySQL database as a .tar archive. Alternatively, to create an image that is a snapshot of your running container, use docker commit. Using either type of backup, you could easily launch your containers on another Docker host if you ever needed to. If you run your Docker containers in production, you should plan to backup regularly.