Matomo logo

Matomo

Open-source web analytics platform and alternative to Google Analytics

Alternative to: Google Analytics


Matomo is a full-featured, self-hosted web analytics platform that gives you complete ownership and control of your visitor data. It aims to be a free/libre software alternative to Google Analytics, with privacy and GDPR compliance built in, and is used on more than 1,400,000 websites worldwide.

Matomo Docker Compose example

Self-host Matomo on your own server, homelab, or VPS starting from this Docker Compose example. It runs Matomo in Docker containers using the official mariadb:lts, matomo:latest images, with persistent volumes and automatic restarts preconfigured. Review the environment variables and adjust them to your setup, save the file as compose.yml (or docker-compose.yml), and start the stack with docker compose up -d.

services:
  db:
    image: mariadb:lts
    command: --max-allowed-packet=64MB
    restart: unless-stopped
    volumes:
      - db:/var/lib/mysql
    environment:
      MARIADB_AUTO_UPGRADE: "1"
      MARIADB_DISABLE_UPGRADE_BACKUP: "1"
      MARIADB_INITDB_SKIP_TZINFO: "1"
      # Name of the MariaDB database Matomo stores its data in.
      MARIADB_DATABASE: "matomo"
      # MariaDB user Matomo connects as.
      MARIADB_USER: "matomo"
      # Password for the Matomo MariaDB user. Only used inside the compose network.
      MARIADB_PASSWORD: "changeme"
      # Password for the MariaDB root user. Only used inside the compose network.
      MARIADB_ROOT_PASSWORD: "changeme-root"

  app:
    image: matomo:latest
    restart: unless-stopped
    volumes:
      - matomo:/var/www/html
    depends_on:
      - db
    environment:
      # Database driver Matomo uses (mysql works for MariaDB too).
      MATOMO_DATABASE_ADAPTER: "mysql"
      # Hostname of the database service Matomo connects to.
      MATOMO_DATABASE_HOST: "db"
      # Prefix applied to all Matomo database tables.
      MATOMO_DATABASE_TABLES_PREFIX: "matomo_"
      # Database name Matomo connects to; must match MARIADB_DATABASE.
      MATOMO_DATABASE_DBNAME: "matomo"
      # Database user Matomo connects as; must match MARIADB_USER.
      MATOMO_DATABASE_USERNAME: "matomo"
      # Password Matomo connects with; must match MARIADB_PASSWORD.
      MATOMO_DATABASE_PASSWORD: "changeme"

volumes:
  db:
  matomo:

Values set to changeme are required — replace them with your own values before starting Matomo.

Prefer a managed setup? WinterFlow installs, configures, and updates Matomo for you using this same Docker Compose configuration.