TOWERBY CETMIX
← Hangar / jet_template_clickhouse_docker

Shared ClickHouse in Docker for Analytics

Deploy a password-protected ClickHouse server with persistent storage, configurable log retention and weekly system-log cleanup.

↓ Download↓ 1 download

Summary

Category
Jet Templates
Tags
Database
Authors
Cetmix OÜ
License
AGPL-3
Version
1.0.0
Call sign
jet_template_clickhouse_docker

This snippet imports the ClickHouse Docker Jet Template. It runs one shared ClickHouse instance per server, defaults to clickhouse/clickhouse-server:24.12-alpine, and includes the Docker, Fail2ban and Tower Core dependency templates. ClickHouse listens over IPv4 on the shared Tower Docker network. Applications such as Plausible connect to the Jet reference on HTTP port 8123. The container publishes no host ports and stores its database files and server logs in separate Docker volumes.

Configure and launch

  1. Import the YAML and install the template on the target server. Set clickhouse_user if you need a login other than tower. Build generates a server-scoped clickhouse_password if that server has no value yet. A Tower manager for the server or a root user can run this step.
  2. Review clickhouse_low_resources, which is enabled by default. It reduces the mark cache and limits parallel processing in the default profile. Review log settings as needed. By default, ClickHouse rotates its server log files at 100M with three files, Docker rotates container logs at 50m with three files, and selected ClickHouse system log tables have a 30-day retention period. Other configured system logs are disabled.
  3. Create a Jet targeting Running. Build renders the XML configuration, creates the volumes and creates the container. Start launches ClickHouse and waits for its local HTTP /ping endpoint.

Operate and troubleshoot

  • Apply configuration rewrites the XML files and restarts a running Jet. Use Rebuild from Stopped to recreate the container for image, login or Docker log option changes while keeping its volumes.
  • The included weekly task drops disabled system log tables and numbered copies left by earlier schema changes. Start and Apply configuration also perform this cleanup unless clickhouse_drop_stale_system_logs is set to no.
  • Use ClickHouse container log, ClickHouse error log and ClickHouse disk usage by table to diagnose startup errors or storage growth. For application connection failures, check the Jet hostname, shared Docker network and server-scoped credentials.
  • Remove removes the container and image. Destroy deletes the Jet root and labeled volumes, including the shared databases and server logs. If teardown manages a Cloudflare record for the Jet, it uses cloudflare_token and cloudflare_zone_id.