How to easily host Matomo with Docker

Docker Matomo Analytics SEO Marketing

Google Analytics is the defacto standard for website operators in the area of website traffic analysis. Not everyone wants to send their website data directly to Google, and not everyone wants to be dependent on a company.

The Google Analytics alternative: Matomo

Many don't even know that there are alternatives to Google Analytics. A Google Analytics alternative to install yourself is Matomo, the former Piwik. Matomo is an open source solution and in my opinion even better than Google Analytics in some points. This article describes how to install Matomo quickly and easily with Docker.

Matomo briefly introduced

Matomo is extremely extensive and, like Google Analytics, also offers analyzes and reports on top keywords and search engines, websites, social media websites, top page URLs, page titles, user countries, providers, operating system, browser market distribution, screen resolution, desktop VS-Mobile, engagement (time on site, pages per visit, repeated visits), top campaigns, custom variables, top entry / exit pages, downloaded files and much more.

What I personally like about Matomo is that it offers many functions and tools for GDPR. There is an opt-out form that can be integrated directly into the data protection settings as an IFrame to deactivate tracking. Matomo is also economical when it comes to creating cookies. Since you have full control over the system, you can determine exactly which data is analyzed and deal with it in your data protection regulations. How long something is saved is up to you and you can simply clean up the system. The data is also on your server, not somewhere in the USA or other European countries.

Requirements for the Docker installation

Matomo can easily be installed without Docker, but it's much easier and faster with Docker. If you decide against Matomo, you have freed your system from Matomo faster and cleaner than if you manually installed the software on your server.

For local tests you need:

  • Docker
  • Docker compose
  • A Linux system or at least Windows 10 Pro

For productive use you need:

  • Docker
  • Docker compose
  • A Linux system (VPS) or Windows server
  • A (sub) domain so that your website can send data to Matomo
  • A website to connect to Matomo

What could the hosting look like?

The hosting ultimately works very simply. You need an internet address to which your website can send visitor information. This works like with Google Analytics via embedded JavaScript and / or an image, provided JavaScript is blocked. I find it most practical if you create a subdomain with your provider e.g. Your Matomo installation runs on and your website could be delivered via Of course, as with Google Analytics, you can connect several websites to a Matomo installation. For me you did the installation as follows: At Contabo I installed a reverse proxy (Nginx) on which my subdomain and my top-level domain show. Depending on the domain / subdomain, the traffic is forwarded to my Docker server at home. My websites and my Matomo run on this.

Download from GitHub

I created a Docker-Compose file for you to install Matomo. You can find the latest version in my GitHub repository for Matomo. Download the complete directory and adapt the user names and passwords to your ideas in the db.env file. If necessary, adjust the port in the Docker-Compose file. This is set to 8090 by default. Then run the Docker-Compose file with admin (root) rights. On Linux this works as follows:

sudo docker-compose up

You can then access Matomo with "hostname: 8090", establish the database connection and create an administrator user.

The Docker Compose file

The Docker Compose file describes which services (containers) should be pulled up. At Matomo, this is a MariaDB database (alternatively MySQL) and Matomo itself. So that the data from the MariaDB database and Matomo are persistent, two named volumes are created in which the data is stored. You should back up these volumes using RSync or a method of your choice.

version: "3"

    image: mariadb
    command: --max-allowed-packet=64MB
    restart: always
      - db:/var/lib/mysql
      - MYSQL_ROOT_PASSWORD=matomo
      - ./db.env

    image: matomo
    restart: always
      - ./config:/var/www/html/config
      - ./logs:/var/www/html/logs
      - matomo:/var/www/html
      - ./db.env
      - 8090:80


The db.env file

The db.env file describes how the database for Matomo should be installed


Previous Post Next Post

Add a comment