docker.recipes

Plausible Analytics

intermediate

Plausible privacy-friendly web analytics alternative to Google Analytics.

Overview

Plausible Analytics is an open-source, privacy-focused web analytics platform that serves as a lightweight alternative to Google Analytics. Founded in 2019, Plausible emphasizes user privacy by design, requiring no cookies, collecting no personal data, and maintaining full GDPR compliance while providing essential website insights. The platform generates a tracking script that's 45x smaller than Google Analytics, ensuring minimal impact on site performance. This stack combines Plausible with PostgreSQL for metadata storage and ClickHouse for high-performance event analytics. PostgreSQL handles user accounts, site configurations, and dashboard data with its robust ACID compliance, while ClickHouse excels at processing millions of pageview events with columnar storage optimized for real-time analytics queries. The dual-database architecture allows Plausible to maintain fast dashboard responses even when processing billions of events. This configuration is ideal for organizations prioritizing user privacy, regulatory compliance, and performance while maintaining comprehensive analytics capabilities. The stack eliminates dependency on third-party analytics services, provides complete data ownership, and offers transparent insights without compromising visitor privacy or requiring cookie consent banners.

Key Features

  • Privacy-first analytics with no cookies or personal data collection
  • Lightweight 1.7KB tracking script that loads 45x faster than Google Analytics
  • Real-time event processing using ClickHouse columnar database for billion-row analytics
  • PostgreSQL-backed user management with ACID-compliant configuration storage
  • GDPR, CCPA, and PECR compliant by design without requiring cookie banners
  • Open-source transparency with self-hosted data ownership
  • Simple dashboard showing essential metrics without complex goal funnels
  • API access for custom integrations and automated reporting

Common Use Cases

  • 1Privacy-conscious businesses replacing Google Analytics for GDPR compliance
  • 2SaaS companies tracking product usage without compromising user privacy
  • 3Publishers and bloggers monitoring content performance with lightweight tracking
  • 4E-commerce sites analyzing traffic patterns while maintaining customer trust
  • 5Government and healthcare organizations requiring strict data sovereignty
  • 6Marketing agencies offering privacy-compliant analytics to clients
  • 7Educational institutions tracking website engagement without student data concerns

Prerequisites

  • Docker Engine 20.10+ and Docker Compose v2 for container orchestration
  • Minimum 4GB RAM (2GB for ClickHouse, 1GB for PostgreSQL, 1GB for Plausible)
  • Domain name or public IP address for BASE_URL configuration
  • Generated SECRET_KEY_BASE using openssl rand -base64 64 command
  • Port 8000 available for Plausible web interface access
  • Understanding of environment variables for initial admin account setup

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:v2.0
4 container_name: plausible
5 command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
6 environment:
7 - BASE_URL=${BASE_URL}
8 - SECRET_KEY_BASE=${SECRET_KEY_BASE}
9 - DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/plausible
10 - CLICKHOUSE_DATABASE_URL=http://clickhouse:8123/plausible
11 - DISABLE_REGISTRATION=${DISABLE_REGISTRATION}
12 ports:
13 - "8000:8000"
14 depends_on:
15 postgres:
16 condition: service_healthy
17 clickhouse:
18 condition: service_started
19 networks:
20 - plausible-network
21
22 postgres:
23 image: postgres:16-alpine
24 container_name: plausible-db
25 environment:
26 - POSTGRES_USER=${POSTGRES_USER}
27 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
28 - POSTGRES_DB=plausible
29 volumes:
30 - postgres_data:/var/lib/postgresql/data
31 healthcheck:
32 test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
33 interval: 10s
34 timeout: 5s
35 retries: 5
36 networks:
37 - plausible-network
38
39 clickhouse:
40 image: clickhouse/clickhouse-server:23.11-alpine
41 container_name: plausible-events
42 volumes:
43 - clickhouse_data:/var/lib/clickhouse
44 ulimits:
45 nofile:
46 soft: 262144
47 hard: 262144
48 networks:
49 - plausible-network
50
51volumes:
52 postgres_data:
53 clickhouse_data:
54
55networks:
56 plausible-network:
57 driver: bridge

.env Template

.env
1# Plausible Analytics
2BASE_URL=http://localhost:8000
3SECRET_KEY_BASE=your-secret-key-base-at-least-64-chars
4POSTGRES_USER=plausible
5POSTGRES_PASSWORD=plausible_password
6DISABLE_REGISTRATION=false

Usage Notes

  1. 1Dashboard at http://localhost:8000
  2. 2Add script to your website
  3. 3GDPR compliant, no cookies
  4. 4Lightweight tracking script
  5. 5Set DISABLE_REGISTRATION=true after setup

Individual Services(3 services)

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

plausible
plausible:
  image: plausible/analytics:v2.0
  container_name: plausible
  command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
  environment:
    - BASE_URL=${BASE_URL}
    - SECRET_KEY_BASE=${SECRET_KEY_BASE}
    - DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/plausible
    - CLICKHOUSE_DATABASE_URL=http://clickhouse:8123/plausible
    - DISABLE_REGISTRATION=${DISABLE_REGISTRATION}
  ports:
    - "8000:8000"
  depends_on:
    postgres:
      condition: service_healthy
    clickhouse:
      condition: service_started
  networks:
    - plausible-network
postgres
postgres:
  image: postgres:16-alpine
  container_name: plausible-db
  environment:
    - POSTGRES_USER=${POSTGRES_USER}
    - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    - POSTGRES_DB=plausible
  volumes:
    - postgres_data:/var/lib/postgresql/data
  healthcheck:
    test:
      - CMD-SHELL
      - pg_isready -U ${POSTGRES_USER}
    interval: 10s
    timeout: 5s
    retries: 5
  networks:
    - plausible-network
clickhouse
clickhouse:
  image: clickhouse/clickhouse-server:23.11-alpine
  container_name: plausible-events
  volumes:
    - clickhouse_data:/var/lib/clickhouse
  ulimits:
    nofile:
      soft: 262144
      hard: 262144
  networks:
    - plausible-network

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 plausible:
5 image: plausible/analytics:v2.0
6 container_name: plausible
7 command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
8 environment:
9 - BASE_URL=${BASE_URL}
10 - SECRET_KEY_BASE=${SECRET_KEY_BASE}
11 - DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/plausible
12 - CLICKHOUSE_DATABASE_URL=http://clickhouse:8123/plausible
13 - DISABLE_REGISTRATION=${DISABLE_REGISTRATION}
14 ports:
15 - "8000:8000"
16 depends_on:
17 postgres:
18 condition: service_healthy
19 clickhouse:
20 condition: service_started
21 networks:
22 - plausible-network
23
24 postgres:
25 image: postgres:16-alpine
26 container_name: plausible-db
27 environment:
28 - POSTGRES_USER=${POSTGRES_USER}
29 - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
30 - POSTGRES_DB=plausible
31 volumes:
32 - postgres_data:/var/lib/postgresql/data
33 healthcheck:
34 test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER}"]
35 interval: 10s
36 timeout: 5s
37 retries: 5
38 networks:
39 - plausible-network
40
41 clickhouse:
42 image: clickhouse/clickhouse-server:23.11-alpine
43 container_name: plausible-events
44 volumes:
45 - clickhouse_data:/var/lib/clickhouse
46 ulimits:
47 nofile:
48 soft: 262144
49 hard: 262144
50 networks:
51 - plausible-network
52
53volumes:
54 postgres_data:
55 clickhouse_data:
56
57networks:
58 plausible-network:
59 driver: bridge
60EOF
61
62# 2. Create the .env file
63cat > .env << 'EOF'
64# Plausible Analytics
65BASE_URL=http://localhost:8000
66SECRET_KEY_BASE=your-secret-key-base-at-least-64-chars
67POSTGRES_USER=plausible
68POSTGRES_PASSWORD=plausible_password
69DISABLE_REGISTRATION=false
70EOF
71
72# 3. Start the services
73docker compose up -d
74
75# 4. View logs
76docker 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-analytics/run | bash

Troubleshooting

  • Database connection errors during startup: Increase the sleep timer in the Plausible command from 10 to 30 seconds to allow PostgreSQL full initialization
  • ClickHouse memory allocation failures: Increase Docker Desktop memory limit to 6GB+ or add memory limits to clickhouse service
  • Site not showing in dashboard after adding script: Verify BASE_URL matches exactly including protocol (https://) and check browser console for CORS errors
  • Registration disabled but can't access dashboard: Create admin user with docker-compose exec plausible /entrypoint.sh db create-admin command
  • High memory usage over time: Configure ClickHouse data retention policies using TTL settings to automatically clean old analytics data
  • Script blocked by ad blockers: Host Plausible on subdomain of tracked site or configure proxy to serve analytics script from same domain

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