Docker Quick Start

Start Kafka and CrateDB using Docker Compose

# docker-compose.yml
services:
  kafka:
    image: bitnami/kafka:latest
    container_name: kafka
    environment:
      - KAFKA_CFG_NODE_ID=1
      - KAFKA_CFG_PROCESS_ROLES=broker,controller
      - KAFKA_CFG_LISTENERS=PLAINTEXT://:9092,CONTROLLER://:9093
      - KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://kafka:9092
      - KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT
      - KAFKA_CFG_CONTROLLER_LISTENER_NAMES=CONTROLLER
      - KAFKA_CFG_CONTROLLER_QUORUM_VOTERS=1@kafka:9093
      - KAFKA_CFG_INTER_BROKER_LISTENER_NAME=PLAINTEXT
      - KAFKA_ENABLE_KRAFT=yes
      - ALLOW_PLAINTEXT_LISTENER=yes
    ports:
      - "9092:9092"
    networks: [ demo ]

  cratedb:
    image: crate:latest
    container_name: cratedb
    command: ["crate", "-Ccluster.name=crate-demo", "-Chttp.cors.enabled=true", "-Chttp.cors.allow-origin=*"]
    ports:
      - "4200:4200"   # HTTP API / Admin UI
      - "5432:5432"   # PostgreSQL wire protocol
    networks: [ demo ]

networks:
  demo: {}

Accessing Crate and Kafka

  • CrateDB Admin UI: http://localhost:4200

  • Kafka broker (inside-compo

  • se hostname): kafka:9092

Create a demo table in CrateDB

The easiest way to do this is through the CrateDB cloud UI at http:://localhost:4200 and execute this using the console:

But this can also be done using curl:

Create a Kafka topic and send a couple of messages

This can be done in several ways, but we can use docker-exec in this way:

Messages are newline-delimited JSON for simplicity.

Create a simple consumer using Python

Run this with:

circle-info

This shows the custom client path: transform/filter as you like, do idempotent upserts on (device_id, ts), and batch writes for speed.

Verifying the data

Last updated