---
title: "Deploy ClickHouse on Pethost in one click"
description: "A fast column-oriented database for analytics, with SQL over HTTP. A template for Pethost: in a minute or two the app is live on your machine, with HTTPS at its own address and nightly backups."
---

[← All templates](https://pethost.dev/templates/)

# Deploy ClickHouse on Pethost in one click

A fast column-oriented database for analytics, with SQL over HTTP

[Deploy on Pethost](https://console.pethost.dev/?template=clickhouse)

## What happens

1. You sign in to Pethost or make an account, with a passkey, GitHub or Google.
2. No machine yet? You pick a plan, and we prepare one for you. The link waits in your browser until it is ready.
3. New project opens at the app. You fill in what it asks for and click Create project: **Admin password**.
4. In a minute or two the app is live at its own address with HTTPS. Its secrets are made for it at random, and its data is in the nightly backup.
5. It is a project like any other: its compose.yaml, its .env, its logs and a terminal are in the panel, and your agent can change it, roll it back or restore it.

## First steps

Open https://clickhouse.sam.pethost.app/play and sign in as default with the admin password you gave. Clients that speak ClickHouse’s HTTP interface connect to https://clickhouse.sam.pethost.app on port 443; the native protocol on port 9000 is not reachable. Data is kept in /var/lib/clickhouse.

## What it runs

The template is this compose.yaml and the variables it writes into the project’s .env. Pethost runs the file as it is written.

```
services:
  clickhouse:
    image: clickhouse/clickhouse-server:26.8.27.9
    restart: unless-stopped
    environment:
      # The user default, with the password given: without one the image lets it in from the
      # container's network only, and the HTTP interface would be closed to everyone.
      CLICKHOUSE_USER: default
      CLICKHOUSE_PASSWORD: ${ADMIN_PASSWORD}
      CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: "1"
    # The stock config logs at trace level into ten files of 1000 MB and keeps its query, metric and
    # trace tables for ever: on a small machine they would fill the disk over months. This keeps the
    # server's log under 300 MB and those tables a week.
    entrypoint:
      - sh
      - -c
      - |
        cat > /etc/clickhouse-server/config.d/small-machine.xml <<'XML'
        <clickhouse>
          <logger><level>information</level><size>100M</size><count>3</count></logger>
          <query_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></query_log>
          <metric_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></metric_log>
          <asynchronous_metric_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></asynchronous_metric_log>
          <trace_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></trace_log>
          <text_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></text_log>
          <part_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></part_log>
          <error_log><ttl>event_date + INTERVAL 7 DAY DELETE</ttl></error_log>
        </clickhouse>
        XML
        exec /entrypoint.sh
    volumes:
      - data:/var/lib/clickhouse
volumes:
  data:
```

[compose.yaml](https://pethost.dev/templates/clickhouse/compose.yaml)[See it on GitHub](https://github.com/pethost-dev/templates/tree/main/clickhouse)

Pethost · Stephan Gomer · NIP 1133096755

[Templates](https://pethost.dev/templates/) [About](https://pethost.dev/about/) [Blog](https://pethost.dev/blog/) [Terms](https://pethost.dev/terms/) [Privacy](https://pethost.dev/privacy/) [Refunds](https://pethost.dev/refunds/) [API](https://pethost.dev/docs/api/) [CLI](https://pethost.dev/docs/cli/) [Plugin](https://github.com/pethost-dev/plugin) [support@pethost.dev](mailto:support@pethost.dev)
