Ryan Schachte's Blog
ClickHouse, Grafana and Tabix setup in Docker January 1st, 2025

Recently I’ve been exploring ClickHouse for persisting data, Grafana for sourcing ClickHouse data for visualizations and Tabix for adhoc queries against ClickHouse. This is a simple recipe for running all 3 locally via Docker/Docker Compose.

Update: You can view a repo I added that will get you setup with Docker, Tabix, Grafana and ClickHouse very easily https://github.com/Schachte/strava-clickhouse


Table of Contents

Directory structure

tree .
.
├── docker-compose.yml
└── volumes
    ├── clickhouse
   ├── config.xml
   ├── logs
   └── clickhouse-server
       ├── clickhouse-server.err.log
       └── clickhouse-server.log
   └── users.xml
    └── grafana
        └── datasources

docker-compose

docker-compose.yml
services:
  clickhouse:
    image: clickhouse/clickhouse-server
    user: "101:101"
    container_name: clickhouse
    hostname: clickhouse
    volumes:
      - ${PWD}/volumes/clickhouse/users.xml:/etc/clickhouse-server/users.d/users.xml
      - ${PWD}/volumes/clickhouse/logs/clickhouse-server/:/var/log/clickhouse-server/
    ports:
      - "8123:8123"
      - "9000:9000"
 
  grafana:
    image: grafana/grafana
    container_name: grafana
    hostname: grafana
    volumes:
      - ${PWD}/volumes/grafana/datasources:/etc/grafana/provisioning/datasources
    ports:
      - "3000:3000"
    depends_on:
      - clickhouse
 
  tabix:
    image: spoonest/clickhouse-tabix-web-client:latest
 
    # because I'm running on M1 Mac (ARM architecture)
    platform: linux/amd64
    container_name: tabix
    hostname: tabix
    ports:
      - "8080:80"
    depends_on:
      - clickhouse

You can tweak the mounted volumes of course (especially in production).

  • Added a custom user in users.xml
  • Able to catch server failures and analyze them on the host by mounting dir into /var/logs on the container

Adding users

Read more about this here: https://clickhouse.com/docs/en/operations/settings/settings-users.

users.xml
<clickhouse>
    <users>
        <schachte>
            <password>password</password>
            <networks>
                <ip>::/0</ip>
            </networks>
            <profile>default</profile>
            <quota>default</quota>
            <access_management>1</access_management>
        </schachte>
    </users>
</clickhouse>

Default logins

Default logins for each container:

Care to comment?