Plausible Analytics logo

Plausible Analytics

Privacy-friendly web analytics platform

Alternative to: Google Analytics, Matomo


Plausible Analytics is an easy to use, lightweight, open source and privacy-friendly alternative to Google Analytics. It doesn’t use cookies and is fully compliant with GDPR, CCPA and PECR.

Plausible Analytics Docker Compose example

Self-host Plausible Analytics on your own server, homelab, or VPS starting from this Docker Compose example. It runs Plausible Analytics in Docker containers using the official ghcr.io/plausible/community-edition:latest, postgres:16-alpine, clickhouse/clickhouse-server:24.12-alpine 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:
  plausible:
    image: ghcr.io/plausible/community-edition:latest
    restart: unless-stopped
    command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh run"
    depends_on:
      - plausible_db
      - plausible_events_db
    environment:
      # Required variables
      BASE_URL: "http://localhost"
      DISABLE_REGISTRATION: "false"
      # openssl rand -base64 48
      SECRET_KEY_BASE: "wuJos4SR0XEQFy3zvTsrsMYZHMVTB8SiYf6aROrX8FbsRYjMI5qvRzbMPai0z0JT"
      POSTGRES_PASSWORD: "postgres"
      # Optional variables
      # openssl rand -base64 32
      TOTP_VAULT_KEY: "523IwrsUM/G00VqSK6Udn2Wif6mpnyjUglCpxZn+CCA="

  plausible_db:
    image: postgres:16-alpine
    restart: unless-stopped
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      # Required variables
      BASE_URL: "http://localhost"
      DISABLE_REGISTRATION: "false"
      # openssl rand -base64 48
      SECRET_KEY_BASE: "wuJos4SR0XEQFy3zvTsrsMYZHMVTB8SiYf6aROrX8FbsRYjMI5qvRzbMPai0z0JT"
      POSTGRES_PASSWORD: "postgres"
      # Optional variables
      # openssl rand -base64 32
      TOTP_VAULT_KEY: "523IwrsUM/G00VqSK6Udn2Wif6mpnyjUglCpxZn+CCA="

  plausible_events_db:
    image: clickhouse/clickhouse-server:24.12-alpine
    restart: unless-stopped
    volumes:
      - event-data:/var/lib/clickhouse
      - event-logs:/var/log/clickhouse-server
      - ./clickhouse/clickhouse-config.xml:/etc/clickhouse-server/config.d/logging.xml:ro
      - ./clickhouse/clickhouse-user-config.xml:/etc/clickhouse-server/users.d/logging.xml:ro
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    environment:
      - CLICKHOUSE_SKIP_USER_SETUP=1

volumes:
  db-data:
    driver: local
  event-data:
    driver: local
  event-logs:
    driver: local

Extra files

The Docker Compose configuration above bind-mounts the following files. Save them next to your compose.yml, keeping the same relative paths.

clickhouse/clickhouse-config.xml

<clickhouse>
    <logger>
        <level>warning</level>
        <console>true</console>
    </logger>
    
    <!-- 
    Avoid the warning: "Listen [::]:9009 failed: Address family for hostname not supported". 
    If Docker has IPv6 disabled, bind ClickHouse to IPv4 to prevent this issue. 
    Add this to the configuration to ensure it listens on all IPv4 interfaces:
    <listen_host>0.0.0.0</listen_host>
    -->

    <!-- Stop all the unnecessary logging -->
    <query_thread_log remove="remove"/>
    <query_log remove="remove"/>
    <text_log remove="remove"/>
    <trace_log remove="remove"/>
    <metric_log remove="remove"/>
    <asynchronous_metric_log remove="remove"/>
    <session_log remove="remove"/>
    <part_log remove="remove"/>
</clickhouse>

clickhouse/clickhouse-user-config.xml

<clickhouse>
    <profiles>
        <default>
            <log_queries>0</log_queries>
            <log_query_threads>0</log_query_threads>
        </default>
    </profiles>
</clickhouse>

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