Run a single-node CockroachDB cluster in Docker, explore distributed SQL, and inspect ranges and execution plans.
| 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 |
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.
🇮🇸 Iceland · 🇳🇿 New Zealand · 🇨🇭 Switzerland · 🇸🇮 Slovenia · 🇮🇪 Ireland · 🇦🇹 Austria · 🇵🇹 Portugal · 🇸🇬 Singapore · 🇫🇮 Finland
Run a single-node CockroachDB cluster in Docker, explore distributed SQL, and inspect ranges and execution plans.
Run a single-node CockroachDB cluster in Docker, explore distributed SQL, and inspect ranges and execution plans.
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.
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| 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 |
| 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. |
- Add a
productstable with aJSONBcolumn and query a field with->>. - Run
SHOW RANGES FROM TABLE ordersand explain what a range is in one sentence. - Compare
EXPLAINandEXPLAIN ANALYZEfor the join query. - Start a second node (requires a multi-node Compose file) and watch the replica count change.
--insecuredisables 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.
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.
docker compose down -v-v also removes the named volume, so the next start is a clean slate.
Part of the database-labs collection: 26 database engines, one index.
MIT (c) 2026 Arya Fatthurahman. See LICENSE.
Full Tech Stack Wall
Connection names shown in the DBX sidebar - decorative reference badges.