Skip to content

About

Run a single-node CockroachDB cluster in Docker, explore distributed SQL, and inspect ranges and execution plans.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

cockroachdb-lab

Run a single-node CockroachDB cluster in Docker, explore distributed SQL, and inspect ranges and execution plans.

At a glance

Field Detail
Repository cockroachdb-lab
Primary language Mixed / documentation
Topics cockroachdb, database, database-labs, devarent, distributed-sql, docker, lab, postgresql
License MIT
Branch main
Maintainer @devarent

Overview

cockroachdb-lab is a hands-on repository focused on: Run a single-node CockroachDB cluster in Docker, explore distributed SQL, and inspect ranges and execution plans.. Primary language: Mixed / documentation. Topics: cockroachdb, database, database-labs, devarent, distributed-sql, docker, lab, postgresql. The README below documents the project; use the table above for a quick overview.

Global references

🇮🇸 Iceland · 🇳🇿 New Zealand · 🇨🇭 Switzerland · 🇸🇮 Slovenia · 🇮🇪 Ireland · 🇦🇹 Austria · 🇵🇹 Portugal · 🇸🇬 Singapore · 🇫🇮 Finland


cockroachdb-lab LANG multi STARS 0 LICENSE MIT
OPEN SOURCE BUILT IN PUBLIC HANDS ON LABS DOCUMENTED

Run a single-node CockroachDB cluster in Docker, explore distributed SQL, and inspect ranges and execution plans.


Arya Fatthurahman

CockroachDB Lab

Run a single-node CockroachDB cluster in Docker, explore distributed SQL, and inspect ranges and execution plans.

Database: CockroachDB Category: Distributed SQL Runs in Docker License: MIT compose-check

What this lab is

CockroachDB speaks the PostgreSQL wire protocol but behaves like a distributed system. This lab starts a single-node cluster in insecure mode, gives you a schema, and shows the commands that make the distributed nature visible: ranges, replicas, and EXPLAIN.

Quickstart

docker compose up -d
docker compose exec -T cockroach cockroach sql --insecure --host=localhost:26257 < examples/01_schema.sql
docker compose exec -T cockroach cockroach sql --insecure --host=localhost:26257 < examples/02_queries.sql
open http://localhost:8080

Connection details

Field Value
Host localhost
SQL port 26257
Admin UI http://localhost:8080
Database defaultdb
User root
JDBC URL jdbc:postgresql://localhost:26257/defaultdb?sslmode=disable
cockroach sql cockroach sql --insecure --host=localhost:26257

Examples

File What it shows
docker-compose.yml Engine, ports, and persistent volume.
.github/workflows/compose-check.yml Validates the Compose file on every push.
examples/01_schema.sql UUID keys, a foreign key, and a secondary index.
examples/02_queries.sql Seed data, an aggregation, SHOW RANGES, and EXPLAIN.

Exercises

  1. Add a products table with a JSONB column and query a field with ->>.
  2. Run SHOW RANGES FROM TABLE orders and explain what a range is in one sentence.
  3. Compare EXPLAIN and EXPLAIN ANALYZE for the join query.
  4. Start a second node (requires a multi-node Compose file) and watch the replica count change.

Notes and limits

  • --insecure disables TLS and authentication. It is only appropriate for a local lab.
  • The Admin UI on port 8080 shows ranges, replicas, and statement statistics.
  • CockroachDB is PostgreSQL wire-compatible, so the PostgreSQL JDBC driver works.
  • The pinned tag is a stable release; check the upstream release notes before upgrading.

Run it from anywhere

This lab publishes its ports on 127.0.0.1 only. To use it from another country, do not open the database port to the internet. Pick one:

  • VPS + private tunnel: run the lab on a small Ubuntu VPS, keep the port closed, and connect through WireGuard or ssh -L.
  • Managed service: use a managed free tier for this engine and point the same examples at its connection string.
  • HTTP UI only: if the engine has a web UI, put it behind Caddy with TLS and basic auth.

The shared checklist, provider map, and commands are in REMOTE-ACCESS.md.

Cleanup

docker compose down -v

-v also removes the named volume, so the next start is a clean slate.

References


Part of the database-labs collection: 26 database engines, one index.

License

MIT (c) 2026 Arya Fatthurahman. See LICENSE.


Tech Stack

Git
Full Tech Stack Wall

Languages
Rust Go TypeScript JavaScript Java Python C C++ Kotlin Swift Ruby PHP Lua Shell

Frontend & Desktop
Vue React Svelte Next.js Nuxt Flutter React Native Tauri Electron Vite HTML5 CSS3 Sass Less Tailwind CSS Bootstrap Three.js Node.js jQuery

Database & Storage
MySQL PostgreSQL SQLite SQL Server Oracle Redis MongoDB DuckDB ClickHouse Elasticsearch Neo4j InfluxDB Cassandra DynamoDB Firebase Supabase MinIO Firebird IBM DB2 MariaDB CockroachDB IRIS Databricks SQL Snowflake Qdrant Redshift Apache Kylin BigQuery VictoriaMetrics Databend TDengine Teradata

Messaging & Streaming
Kafka RabbitMQ RocketMQ Pulsar Flink

DevOps & Cloud Native
Docker Kubernetes Terraform Ansible Jenkins GitHub Actions GitLab CI Prometheus Grafana Nginx AWS Azure Cloudflare

Tools & Platforms
Git Linux macOS VS Code Vim Tmux Homebrew Postman Figma Markdown Maven Gradle CMake

Hands-on engineering, built and documented in the open.

DBX Connections

Firebird_5n1b JDBCX_d5pn IBM DB2_0leg MariaDB_80g9 SQL Server_wieh CockroachDB_mo9c IRIS_cz3h Databricks_SQL_rmue Snowflake_cm_h9 Redis_u0tv Qdrant_1r3s Elasticsearch_zfc3 Cassandra_d8eb MongoDB_vexq Redshift_p9d7 Apache Kylin_xmpz Neo4j_j3dsg BigQuery_homk Apache Kafka_xpqk VictoriaMetrics_m3sf InfluxDB_wuju Databend_dey6 TDengine_4c9i Teradata_rwlm

Connection names shown in the DBX sidebar - decorative reference badges.

About

Run a single-node CockroachDB cluster in Docker, explore distributed SQL, and inspect ranges and execution plans.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors