docker.recipes

Plausible Analytics

intermediate

Lightweight, privacy-friendly Google Analytics alternative

Overview

Plausible Analytics is a lightweight, open-source web analytics platform that serves as a privacy-focused alternative to Google Analytics. Developed with GDPR, CCPA, and PECR compliance in mind, Plausible delivers essential website metrics without using cookies or collecting personal data. The platform provides a clean, intuitive dashboard that displays visitor counts, page views, traffic sources, and device information while maintaining user privacy through data anonymization and aggregation. This stack combines Plausible with PostgreSQL and ClickHouse to create a powerful dual-database architecture optimized for both operational and analytical workloads. PostgreSQL handles user accounts, site configurations, and application metadata with its robust ACID compliance and relational integrity. ClickHouse manages the high-volume event data from website visitors, leveraging its columnar storage and real-time query capabilities to process millions of pageviews efficiently. This separation allows Plausible to maintain fast dashboard performance even with large traffic volumes. This configuration is ideal for privacy-conscious organizations, European businesses requiring GDPR compliance, and anyone seeking full control over their analytics data. The self-hosted approach eliminates third-party data sharing while providing enterprise-grade analytics capabilities. Startups can avoid Google Analytics' data sampling limitations, while larger organizations benefit from unlimited data retention and custom reporting without per-seat licensing costs.

Key Features

  • Cookie-free tracking with <1KB JavaScript snippet that doesn't impact site performance
  • Real-time visitor analytics with ClickHouse-powered sub-second query responses
  • PostgreSQL-backed user management supporting multiple team members and site ownership
  • GDPR-compliant data collection with automatic IP anonymization and EU data residency
  • Custom event tracking and goal conversion measurement without personal data collection
  • ClickHouse columnar compression reducing storage requirements by 80% compared to traditional databases
  • Built-in referrer spam filtering and bot detection using PostgreSQL pattern matching
  • Open-source transparency allowing full audit of data collection and processing methods

Common Use Cases

  • 1European businesses needing GDPR-compliant analytics without consent banners or cookie notices
  • 2Privacy-focused websites wanting visitor insights without compromising user anonymity
  • 3High-traffic sites requiring real-time analytics with ClickHouse's billion-row processing capabilities
  • 4Organizations avoiding Google's data collection while maintaining comprehensive traffic analysis
  • 5SaaS companies tracking product usage and conversion funnels with custom event goals
  • 6News and content sites monitoring article performance and reader engagement patterns
  • 7E-commerce platforms analyzing visitor behavior without storing personal shopping data

Prerequisites

  • Minimum 4GB RAM to support ClickHouse's in-memory operations and PostgreSQL concurrency
  • Docker Engine 20.10+ with docker-compose for multi-container orchestration
  • Available ports 8000 (Plausible), 5432 (PostgreSQL), and 8123 (ClickHouse) or custom port mapping
  • Generate secure SECRET_KEY_BASE using openssl rand -base64 64 for session encryption
  • Domain name or reverse proxy setup for production BASE_URL configuration
  • Understanding of basic SQL for custom ClickHouse queries and PostgreSQL user management

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 plausible:
3 image: plausible/analytics:latest
4 container_name: plausible
5 restart: unless-stopped
6 command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
7 ports:
8 - "${PLAUSIBLE_PORT:-8000}:8000"
9 environment:
10 - BASE_URL=${BASE_URL:-http://localhost:8000}
11 - SECRET_KEY_BASE=${SECRET_KEY_BASE}
12 - DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@plausible_db:5432/plausible_db
13 - CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db
14 depends_on:
15 - plausible_db
16 - plausible_events_db
17
18 plausible_db:
19 image: postgres:16-alpine
20 container_name: plausible_db
21 restart: unless-stopped
22 environment:
23 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
24 - POSTGRES_DB=plausible_db
25 volumes:
26 - plausible_db_data:/var/lib/postgresql/data
27
28 plausible_events_db:
29 image: clickhouse/clickhouse-server:latest
30 container_name: plausible_events_db
31 restart: unless-stopped
32 volumes:
33 - plausible_events_data:/var/lib/clickhouse
34 ulimits:
35 nofile:
36 soft: 262144
37 hard: 262144
38
39volumes:
40 plausible_db_data:
41 plausible_events_data:

.env Template

.env
1# Plausible Configuration
2PLAUSIBLE_PORT=8000
3
4# Your site URL
5BASE_URL=http://localhost:8000
6
7# Secret key (generate with: openssl rand -base64 64)
8SECRET_KEY_BASE=your-64-char-secret-key
9
10# Database password
11POSTGRES_PASSWORD=postgres
12
13# Optional: Email (for registration)
14# MAILER_EMAIL=hello@plausible.local
15# SMTP_HOST_ADDR=mail.example.com

Usage Notes

  1. 1Dashboard at http://localhost:8000
  2. 2First visit creates admin account
  3. 3Add tracking script to your sites
  4. 4GDPR compliant - no cookies by default
  5. 5Lightweight ~1KB tracking script
  6. 6Self-hosted = you own your data

Individual Services(3 services)

Copy individual services to mix and match with your existing compose files.

plausible
plausible:
  image: plausible/analytics:latest
  container_name: plausible
  restart: unless-stopped
  command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
  ports:
    - ${PLAUSIBLE_PORT:-8000}:8000
  environment:
    - BASE_URL=${BASE_URL:-http://localhost:8000}
    - SECRET_KEY_BASE=${SECRET_KEY_BASE}
    - DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@plausible_db:5432/plausible_db
    - CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db
  depends_on:
    - plausible_db
    - plausible_events_db
plausible_db
plausible_db:
  image: postgres:16-alpine
  container_name: plausible_db
  restart: unless-stopped
  environment:
    - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    - POSTGRES_DB=plausible_db
  volumes:
    - plausible_db_data:/var/lib/postgresql/data
plausible_events_db
plausible_events_db:
  image: clickhouse/clickhouse-server:latest
  container_name: plausible_events_db
  restart: unless-stopped
  volumes:
    - plausible_events_data:/var/lib/clickhouse
  ulimits:
    nofile:
      soft: 262144
      hard: 262144

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 plausible:
5 image: plausible/analytics:latest
6 container_name: plausible
7 restart: unless-stopped
8 command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
9 ports:
10 - "${PLAUSIBLE_PORT:-8000}:8000"
11 environment:
12 - BASE_URL=${BASE_URL:-http://localhost:8000}
13 - SECRET_KEY_BASE=${SECRET_KEY_BASE}
14 - DATABASE_URL=postgres://postgres:${POSTGRES_PASSWORD}@plausible_db:5432/plausible_db
15 - CLICKHOUSE_DATABASE_URL=http://plausible_events_db:8123/plausible_events_db
16 depends_on:
17 - plausible_db
18 - plausible_events_db
19
20 plausible_db:
21 image: postgres:16-alpine
22 container_name: plausible_db
23 restart: unless-stopped
24 environment:
25 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
26 - POSTGRES_DB=plausible_db
27 volumes:
28 - plausible_db_data:/var/lib/postgresql/data
29
30 plausible_events_db:
31 image: clickhouse/clickhouse-server:latest
32 container_name: plausible_events_db
33 restart: unless-stopped
34 volumes:
35 - plausible_events_data:/var/lib/clickhouse
36 ulimits:
37 nofile:
38 soft: 262144
39 hard: 262144
40
41volumes:
42 plausible_db_data:
43 plausible_events_data:
44EOF
45
46# 2. Create the .env file
47cat > .env << 'EOF'
48# Plausible Configuration
49PLAUSIBLE_PORT=8000
50
51# Your site URL
52BASE_URL=http://localhost:8000
53
54# Secret key (generate with: openssl rand -base64 64)
55SECRET_KEY_BASE=your-64-char-secret-key
56
57# Database password
58POSTGRES_PASSWORD=postgres
59
60# Optional: Email (for registration)
61# MAILER_EMAIL=hello@plausible.local
62# SMTP_HOST_ADDR=mail.example.com
63EOF
64
65# 3. Start the services
66docker compose up -d
67
68# 4. View logs
69docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/plausible/run | bash

Troubleshooting

  • ClickHouse 'Cannot allocate memory' errors: Increase Docker memory limits to 4GB+ and set ClickHouse max_memory_usage
  • Plausible 'Database migration failed' on startup: Ensure PostgreSQL is fully ready before Plausible starts, increase sleep time in command
  • Missing SECRET_KEY_BASE causes 'KeyError' on first access: Generate 64-character base64 key and restart all services
  • ClickHouse connection refused: Verify port 8123 accessibility and check ClickHouse container logs for initialization errors
  • PostgreSQL 'password authentication failed': Confirm POSTGRES_PASSWORD matches in both DATABASE_URL and PostgreSQL environment
  • High memory usage from ClickHouse: Configure max_memory_usage and max_bytes_before_external_group_by in ClickHouse settings

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space