Matomo on FrankenPHP with unattended setup, GeoIP, Redis/Valkey cache and Kubernetes support
8.8K
Matomo as a single container image, ready for Docker Compose and Kubernetes:
cp .env.example .env # set the passwords and the salt: openssl rand -hex 32
docker compose up -d
open http://localhost:8080
| Option | Processes | Pros | Cons |
|---|---|---|---|
| FrankenPHP (Caddy + embedded PHP) ✅ | 1 | No FPM, no supervisor; automatic HTTPS, HTTP/2+3, zstd/br; configured with environment placeholders; official image with install-php-extensions | Younger project; thread-safe (ZTS) PHP; Matomo only runs in classic mode, not in worker mode |
| Caddy + PHP-FPM | 2 | Mature FPM, Caddy features | Needs a supervisor (s6, supervisord) or two containers sharing the code |
| nginx + PHP-FPM | 2 | Configuration documented by Matomo (matomo-nginx) | Needs a supervisor, no automatic TLS |
Apache + mod_php (official matomo:apache) | 1 | Matomo's .htaccess protection works as is | Heavyweight (prefork), TLS needs another component |
The access rules of matomo-nginx are ported to rootfs/etc/caddy/Caddyfile:
only the Matomo entry points are executed, internal directories are blocked, code directories serve static
assets only.
bitnamilegacy/* in August 2025 and receive no updates.matomo image copies the code into a volume on the first start, which makes updates through
a new image cumbersome, and Docker Hub lags behind the Matomo releases.builds.matomo.org, verified
with the Matomo signing key), but keeps the code immutable in /app. A new Matomo version is a new image./app Matomo (part of the image, owned by root)
bootstrap.php moves PIWIK_USER_PATH and the plugin directory to /var/lib/matomo
plugins/ContainerSetup console commands for configuration, installation, plugins and GeoIP
/etc/matomo optional configuration of the user (read-only, eg. a ConfigMap)
conf.d/*.ini INI settings
config.php DI definitions
/var/lib/matomo all state (volume), the only writable path
config/ config.ini.php, common.config.ini.php and config.php
tmp/ caches, compiled templates, sessions of PHP
geoip/ GeoIP databases (.mmdb)
plugins/ plugins installed from the Marketplace
js/, tagmanager/ generated tracker and Tag Manager containers
misc-user/ custom logos
caddy/ Caddy state (certificates with automatic HTTPS)
The container runs as www-data (UID/GID 82), Caddy listens on 8080 (and 8443 with automatic HTTPS).
matomo-entrypoint runs before the web server starts:
common.config.ini.php and config.php (see configuration)container:configure: waits for the database, creates it if missing, detects the charsetcontainer:init, under a database lock, so containers starting at the same time never install twice or
migrate concurrently:
core:update: database migrations after a version change; settings the migrations write to
config.ini.php are recorded in the database and copied into the config.ini.php of every containercontainer:prepare: GeoIP database download, tracker and Tag Manager files of this containerMATOMO_INIT selects how much of this a container does:
MATOMO_INIT | |
|---|---|
full (default) | everything |
configure | waits until another container or a job has installed Matomo, then only the plugins of this container (step 3, under the lock) and step 4 |
none | nothing, the data directory is provided completely |
Other commands of the image:
| Command | |
|---|---|
init | the initialisation only, then exit (Kubernetes init container or job) |
archive | core:archive every MATOMO_ARCHIVE_INTERVAL seconds, once with 0 (Kubernetes CronJob) |
console <command> | a Matomo console command |
matomo-plugin-download | bundles Marketplace plugins in derived images, see plugins |
Matomo merges three INI files. The container generates the first one on every start, Matomo writes the second:
| Precedence | Source | Written to |
|---|---|---|
| 1 (lowest) | container defaults (logs to stderr, no one-click update, ...) | common.config.ini.php |
| 2 | /etc/matomo/conf.d/*.ini and *.ini.php, alphabetical | common.config.ini.php |
| 3 | environment variables below, MATOMO_CONFIG__<Section>__<key> | common.config.ini.php |
| 4 (highest) | Matomo itself: generated salt, installation state, plugins, changes in the UI | config.ini.php |
Because common.config.ini.php is regenerated, removing a variable or file takes effect on the next start.
DI definitions in /etc/matomo/config.php (returning an array) are merged into Matomo's config.php.
Every variable can also be read from a file with the suffix _FILE, eg. MATOMO_DATABASE_PASSWORD_FILE.
| Variable | Default | Description |
|---|---|---|
MATOMO_DATABASE_HOST | – | Without host the Matomo web installer is used |
MATOMO_DATABASE_PORT | 3306 | |
MATOMO_DATABASE_USERNAME, _PASSWORD, _DBNAME | – | The database is created if it does not exist and the user may |
MATOMO_DATABASE_TABLES_PREFIX | empty | |
MATOMO_DATABASE_ADAPTER | PDO\MYSQL | or MYSQLI |
MATOMO_DATABASE_SCHEMA | Mysql | Mariadb enables MariaDB specific features |
MATOMO_DATABASE_WAIT_TIMEOUT | 120 | Seconds to wait for the database |
MATOMO_SALT | generated | Set it if the data volume is not persistent or not shared by all containers, sessions and tokens depend on it |
MATOMO_AUTO_INSTALL | true | false: finish the installation in the browser |
MATOMO_AUTO_UPDATE | true | Run core:update on start |
MATOMO_ADMIN_USER, _PASSWORD, _EMAIL | – | Required for the unattended installation |
MATOMO_SITE_NAME, _URL, _TIMEZONE, _CURRENCY, _ECOMMERCE | Website, MATOMO_URL, UTC, EUR, false | First website |
MATOMO_INIT | full | See start |
MATOMO_INIT_LOCK_TIMEOUT | 600 | Seconds to wait for the initialisation lock |
MATOMO_INSTALL_WAIT_TIMEOUT | 600 | Seconds MATOMO_INIT=configure waits for the installation |
| Variable | Default | Description |
|---|---|---|
MATOMO_URL | – | Public URL, sets trusted_hosts and the URL used on the command line |
MATOMO_TRUSTED_HOSTS | host of MATOMO_URL | Comma separated. With MATOMO_PROXY_HOST_HEADERS list the public hostname and the hostname the proxy connects to: Matomo 6 checks the public one, and caches the tracker configuration only for a trusted Host header |
MATOMO_PROXY_CLIENT_HEADERS | – | eg. HTTP_X_FORWARDED_FOR behind an ingress |
MATOMO_PROXY_HOST_HEADERS, _SCHEME_HEADERS, MATOMO_PROXY_IPS | – | Comma separated |
MATOMO_ASSUME_SECURE_PROTOCOL, MATOMO_FORCE_SSL | – | true/false |
MATOMO_BROWSER_ARCHIVING | – | false when an archiver runs |
MATOMO_MULTI_SERVER | false | true for several containers without a shared volume, see Kubernetes |
MATOMO_CONFIG__<Section>__<key> | – | Any INI setting, eg. MATOMO_CONFIG__mail__host=smtp.example.org. Values starting with [ are JSON arrays |
MATOMO_ARCHIVE_INTERVAL | 3600 | Command archive: seconds between runs, 0 for a single run |
MATOMO_ARCHIVE_OPTIONS | – | Additional core:archive options, eg. --concurrent-requests-per-website=3 |
With more than one container, Matomo needs a shared cache: with the default file cache every container keeps its own copy and misses the invalidations of the others (new websites, changed settings, ...).
| Variable | Default | Description |
|---|---|---|
MATOMO_REDIS_HOST | – | Enables Redis/Valkey as cache (array + redis chain). tls://host for TLS |
MATOMO_REDIS_PORT | 6379 | |
MATOMO_REDIS_UNIX_SOCKET | – | Instead of host and port |
MATOMO_REDIS_PASSWORD | – | |
MATOMO_REDIS_DATABASE | 14 | Use another database for QueuedTracking |
MATOMO_REDIS_TIMEOUT | 1.0 | Seconds |
Valkey and Redis are both supported, the entries are serialized with igbinary.
| Variable | Default | Description |
|---|---|---|
SERVER_NAME | :8080 | A hostname (analytics.example.org) enables automatic HTTPS on 8443, redirect on 8080 |
CADDY_HTTP_PORT, CADDY_HTTPS_PORT | 8080, 8443 | |
TRUSTED_PROXIES | private_ranges | Proxies Caddy trusts for X-Forwarded-For |
CADDY_SERVER_EXTRA_DIRECTIVES | – | eg. log for access logs |
CADDY_GLOBAL_OPTIONS, FRANKENPHP_CONFIG | – | eg. FRANKENPHP_CONFIG="num_threads 32" |
PHP_MEMORY_LIMIT | 512M | Also used by the archiving |
PHP_MAX_EXECUTION_TIME, PHP_UPLOAD_MAX_FILESIZE, PHP_POST_MAX_SIZE, PHP_OPCACHE_MEMORY | 300, 64M, 64M, 256 |
/healthz is answered by Caddy without PHP (liveness), /matomo.php by PHP (readiness).
| Way | Survives a new container | Several containers without shared volume | Versions |
|---|---|---|---|
Bundled in the image: build argument MATOMO_PLUGINS or a derived image | yes | yes | pinned |
MATOMO_PLUGINS_INSTALL | downloaded again if the volume is not persistent | every container downloads it | latest compatible at the time of the download |
| Marketplace in the UI | with a persistent volume | no, disabled by MATOMO_MULTI_SERVER | latest compatible |
A derived image pins versions, so all containers run the same code (free plugins):
FROM ideaplexus/matomo:6.0.0
USER root
RUN matomo-plugin-download [email protected] LoginLdap
USER 82:82
| Variable | Description |
|---|---|
MATOMO_PLUGINS_INSTALL | Comma separated Marketplace plugins, downloaded into the data directory if missing or if the installed version does not support the Matomo version (eg. after the update to Matomo 6), and activated. Premium plugins need the license key |
MATOMO_PLUGINS_ACTIVATE, MATOMO_PLUGINS_DEACTIVATE | Comma separated plugins, applied on every start |
MATOMO_MARKETPLACE_LICENSE_KEY | License for premium plugins |
The activation state lives in config.ini.php. Every container applies the variables itself under the
initialisation lock, so containers without a shared volume end up with the same plugins. Plugins activated in
the UI are only known to containers sharing the data volume.
Installing from the Marketplace in the UI needs a writable root filesystem: Matomo insists on a writable
/app/plugins, although it stores the plugin in the data directory. MATOMO_PLUGINS_INSTALL works with a
read-only root filesystem.
Two independent settings: where the location comes from (MATOMO_GEOIP_PROVIDER) and which database
is provided (MATOMO_GEOIP_DATABASE, also the fallback of the header providers, eg. for log imports). The PHP
extension maxminddb speeds up all database lookups.
MATOMO_GEOIP_PROVIDER | Source |
|---|---|
database (default) | MMDB database, Matomo provider "GeoIP 2 (PHP)" |
cloudflare | CF-IPCountry; city, region and coordinates need the Cloudflare managed transform "Add visitor location headers". Sets proxy_client_headers to CF-Connecting-IP unless configured |
cloudfront | CloudFront-Viewer-*, add the headers to the origin request policy |
headers | Custom headers via MATOMO_GEOIP_HEADER_<KEY> (COUNTRY_CODE, REGION_CODE, CITY_NAME, LATITUDE, LONGITUDE, POSTAL_CODE, CONTINENT_CODE, ...), also overrides the presets |
default | No geolocation (Matomo guesses the country from the browser language) |
manual | Nothing is changed, configure it in the Matomo UI |
The header providers map the CDN headers in Caddy to the $_SERVER variables of the Matomo provider "GeoIP 2
(HTTP server module)", only for requests from MATOMO_GEOIP_TRUSTED_PROXIES (default private_ranges).
Set the IP ranges of the CDN if it connects directly, otherwise countries can be forged.
MATOMO_GEOIP_DATABASE | Variables |
|---|---|
dbip (default) | MATOMO_GEOIP_DBIP_EDITION=city|country, MATOMO_GEOIP_DBIP_ASN=true for provider data. Free, no account (CC BY 4.0, attribution required) |
maxmind | MATOMO_GEOIP_MAXMIND_LICENSE_KEY (required), MATOMO_GEOIP_MAXMIND_EDITION (GeoLite2-City), MATOMO_GEOIP_MAXMIND_ISP_EDITION (eg. GeoLite2-ASN). Matomo logs the download URL including the license key |
url | MATOMO_GEOIP_LOC_URL, MATOMO_GEOIP_ISP_URL, eg. paid DB-IP downloads. The host must be in geolocation_download_from_trusted_hosts (maxmind.com, db-ip.com, ip2location.com) |
file | Mount the .mmdb files to /var/lib/matomo/geoip/ with Matomo's file names (eg. GeoIP2-City.mmdb) |
none | No database |
| Variable | Default | Description |
|---|---|---|
MATOMO_GEOIP_UPDATE_PERIOD | month | week or month, updates by the Matomo scheduler (runs with the archiving) |
MATOMO_GEOIP_DOWNLOAD_ON_START | missing | missing (also when older than the maximum age), always, never |
MATOMO_GEOIP_MAX_AGE_DAYS | 35 | Containers without a shared volume refresh their databases on start, the scheduler only updates its own container |
A Helm chart is developed separately. The image supports these topologies:
| Topology | Data volume | Notes |
|---|---|---|
| Single replica (Deployment or StatefulSet) | ReadWriteOnce PVC | Everything works like with Compose |
| Replicas with shared volume | ReadWriteMany PVC, mounted by all pods and the CronJob | Plugins and settings from the UI apply to all pods, the scheduler updates GeoIP for all |
| Replicas without shared volume | emptyDir, or a ReadWriteOnce PVC per pod of a StatefulSet | Set MATOMO_SALT and MATOMO_MULTI_SERVER=true; manage plugins with variables or the image |
Every topology with more than one pod needs MATOMO_REDIS_HOST and MATOMO_SALT.
Without a shared volume each pod has its own config.ini.php, plugin directory, GeoIP databases and Tag Manager
files:
MATOMO_MULTI_SERVER=true sets Matomo's multi_server_environment and disables the plugin administration
in the UI, changes there would only reach one podMATOMO_PLUGINS_* and regenerates the Tag Manager containers on start; a container
published in the UI reaches the other pods with their next startMATOMO_GEOIP_MAX_AGE_DAYSMATOMO_INIT=full (default): the first pod installs or migrates, the others wait for the
lock and continue. Rolling updates migrate with the first new pod.MATOMO_INIT=configure: a Helm hook job runs the image with the command init, the
pods wait for the installation and only set up their own plugins.A CronJob runs the image with the command archive and MATOMO_ARCHIVE_INTERVAL=0: one core:archive run,
then exit. Use concurrencyPolicy: Forbid. It needs the same database, cache and plugin variables as the pods
and MATOMO_SALT, it writes its own configuration unless it mounts the shared volume. Set
MATOMO_BROWSER_ARCHIVING=false on the pods.
securityContext: # pod
runAsNonRoot: true
runAsUser: 82
runAsGroup: 82
fsGroup: 82
seccompProfile:
type: RuntimeDefault
containers:
- name: matomo
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true # false only for Marketplace installs in the UI
capabilities:
drop: [ALL]
ports:
- containerPort: 8080
volumeMounts:
- name: data # the only writable path
mountPath: /var/lib/matomo
- name: config # optional ConfigMap with *.ini files
mountPath: /etc/matomo/conf.d
startupProbe: # the first start installs and downloads GeoIP databases
httpGet: {path: /matomo.php, port: 8080}
periodSeconds: 10
failureThreshold: 60
readinessProbe:
httpGet: {path: /matomo.php, port: 8080}
livenessProbe:
httpGet: {path: /healthz, port: 8080}
The image has no file capabilities, so it runs with capabilities: drop: [ALL]. Behind an ingress set
MATOMO_PROXY_CLIENT_HEADERS=HTTP_X_FORWARDED_FOR, MATOMO_ASSUME_SECURE_PROTOCOL=true and MATOMO_URL.
Included besides the extensions of the PHP image: bcmath, gd (graphs), igbinary (Redis cache
serialization), ldap (LoginLdap), maxminddb (GeoIP), mysqli, opcache, pdo_mysql, redis (cache,
QueuedTracking), zip (plugin installation). Matomo's system check reports no missing extension.
Deliberately not included:
| Extension | Why |
|---|---|
imagick | Matomo uses GD for its graphs, only the PDF library could use it for images in PDF reports; adds ImageMagick with a long security history |
apcu | Not used by Matomo (the official image installs it anyway) |
intl | Matomo ships its own locale data |
pdo_pgsql | Matomo 5 only supports MySQL and MariaDB |
Add an extension in a derived image with install-php-extensions <name> as root. The log analytics importer
(misc/log-analytics) is a Python script and runs better outside this image.
Matomo 6 requires MySQL 8.0+ or MariaDB 10.6+ (Matomo 5: MySQL 5.5+ or MariaDB); it publishes no list of supported MariaDB versions. Compose and the tests use MariaDB 12.3, the current long-term support series (maintained until 2029). Renovate only proposes LTS series (x.3), the rolling releases in between are supported for a few months only. The smoke test also passes against MariaDB 11.8 and 13.0.
| Tag | Example | Changes |
|---|---|---|
<Matomo version>-<revision> | 5.14.1-2 | never, one image release |
<Matomo version>, <major>.<minor>, <major> | 5.14.1, 5.14, 5 | with every release of that Matomo version or line |
latest | with every release of the current Matomo major | |
edge | with every build of the default branch, only in Harbor | |
<major>-edge | 5-edge | with every build of a maintenance branch, only in Harbor |
The revision counts the releases of one Matomo version and starts at 1 again with a new Matomo version:
5.14.1-1, 5.14.1-2, then 5.15.0-1. Docker tags cannot carry SemVer build metadata (5.14.1+1), hence
the hyphen. Pin a release, eg. as appVersion of a Helm chart.
:latest and :6 follow Matomo 6. Matomo 5 stays supported as LTS until 23 November 2027, and so does its image:
:5, :5.14 and 5.14.3-<revision> get its releases and the security updates of the base image. Pin :5 (or a
release) to stay on Matomo 5: a container on :latest updates the database on its next start.
The update from 5 to 6:
log_visit, which takes a while on a large installation.container:init runs it once, under the initialisation lock: replicas starting at the same time wait, then find
the database up to date. Old containers keep running during a rolling update; stop them first if the
log_visit change takes long.datatable_archiving_maximum_rows_actions_flat = 0 in config.ini.php), only new installations archive flat.
The container records the setting in the database, so replicas without shared volume, the archiver CronJob and
every later pod keep it too. Set MATOMO_CONFIG__General__datatable_archiving_maximum_rows_actions_flat to switch.MATOMO_PLUGINS_INSTALL replaces
them by a compatible version from the Marketplace, as soon as there is one. Rebuild derived images with versions
for Matomo 6; plugins installed in the UI are updated in the UI.MATOMO_PROXY_HOST_HEADERS, the hostname from the proxy header has to be trusted, see
MATOMO_TRUSTED_HOSTS.Tests, pipeline, releases, Renovate and the changelog: see DEVELOPMENT.md.
Content type
Image
Digest
sha256:582cab44d…
Size
125.5 MB
Last updated
2 days ago
docker pull ideaplexus/matomo