Sign inSign up

aa8y/cockroach-dataset

By aa8y

•Updated 13 days ago

Docker database images with pre-populated data for testing and/or practice.

Image
0

10K+

aa8y/cockroach-dataset repository overview

⁠CockroachDB images — aa8y/cockroach-dataset

The CockroachDB images mirror the PostgreSQL ones — one dataset per image, same ETL Dockerfile⁠ driven by manifest.yml⁠. The engine is CockroachDB⁠ (see Base image⁠ for that choice); it is PostgreSQL wire- and SQL-compatible, so these reuse the same PostgreSQL-dialect dumps the Yugabyte PostgreSQL tags do. The official cockroachdb/cockroach entrypoint creates the database named by the COCKROACH_DATABASE env var and runs every /docker-entrypoint-initdb.d/*.sql script against it (under start-single-node), so — unlike the postgres images — the build emits no CREATE DATABASE header; the database is the bare dataset name.

The available tags are the CockroachDB column of the dataset support matrix⁠, which also lists each dataset's upstream source.

⁠Base image

CockroachDB⁠ as aa8y/cockroach-dataset⁠. There is no official Alpine image (the official cockroachdb/cockroach⁠ image is UBI-minimal), but it is slim (~170 MB) and multi-arch, and its entrypoint honours the same /docker-entrypoint-initdb.d/*.sql convention as the official postgres image (plus a COCKROACH_DATABASE env var) when the container is started with start-single-node. CockroachDB is PostgreSQL wire- and SQL-compatible, so the dataset pattern carries over and these reuse the same PostgreSQL-dialect sample dumps.

⁠Usage

The images run a single-node cluster in insecure mode (these are throwaway practice/test images, mirroring the trivial credentials the postgres/mysql images use), which keeps connecting simple. Start the world image, wait for it to initialize, and query it with the built-in cockroach sql client:

docker run -d --name cr-ds-world aa8y/cockroach-dataset:world
# The first start loads the dataset; give it a moment to initialize.
docker exec -it cr-ds-world cockroach sql --insecure --database world -e 'SELECT count(*) FROM city'

To run a different dataset, swap world for any tag in the CockroachDB column of the matrix⁠; the database inside is the tag name minus any stackexchange- prefix (e.g. stackexchange-beer → beer).

⁠Connecting from the host or another container

Insecure mode means user root with no password on the standard SQL port 26257. CockroachDB is PostgreSQL wire-compatible, so publish the port and connect with psql (or any Postgres client):

docker run -d --name cr-ds-world -p 26257:26257 aa8y/cockroach-dataset:world
psql -h localhost -p 26257 -U root -d world -c 'SELECT count(*) FROM city'

Don't put them anywhere that matters.

⁠CockroachDB datasets

Sources are in the matrix⁠; the notes below are CockroachDB-specific:

  • chinook, northwind: same Yugabyte PostgreSQL-dialect dumps as the postgres chinook / northwind tags (quoted CamelCase identifiers for chinook; snake_case for northwind).
  • sakila: the MySQL DVD-rental sample (the original of pagila), from jOOQ's multi-dialect port collection⁠, which publishes a CockroachDB-specific flavour of the PostgreSQL dump. It loads as published — the mpaa_rating enum, text[], bytea, the four views and every ALTER ... OWNER TO root run unchanged on v25.4 — so cockroach/scripts/sakila is just a symlink to the shared pgfoundry hook, whose job here is the data: 46,273 rows arrive in 15 COPY ... FROM stdin blocks, and CRDB's init-time stdin COPY is far slower than batched INSERTs. 15 base tables, not MySQL's 16: this port has no film_text. Counts match the SQLite sakila tag exactly (including payment at 16,049, where MySQL's own upstream has 16,044).
  • employees: datacharmer's canonical large sample (6 tables + 2 views; 300,024 employees and 2,844,047 salary rows — the heaviest CockroachDB image). CockroachDB runs upstream's PostgreSQL port unchanged apart from its DROP/CREATE DATABASE preamble — foreign keys, CHECK and both views included — but 4.2M rows of init-time INSERTs are hopeless when every batch is a Raft commit, so cockroach/scripts/employees converts the eight data dumps to per-table CSVs, ships them to the node's external-IO dir and loads them with IMPORT INTO ... CSV DATA in dependency order. IMPORT INTO leaves the foreign keys in place but unvalidated (pg_constraint.convalidated = false): the imported rows are consistent by construction and later writes are still enforced against them. Row counts are exact and match the other engines; first boot takes about 6 s.
  • world, iso3166, frenchtowns, usda, dellstore: pgFoundry PostgreSQL DDL + data dumps, transcoded from Latin-1 to UTF-8, stripped of Postgres session settings and setval calls CockroachDB does not need, with COPY blocks rewritten to batched INSERTs at build time (cockroach/scripts/pgfoundry; CRDB's init-time stdin COPY is far slower than Postgres for large blocks). The dellstore PL/pgSQL helper function is dropped (schema and data still load faithfully).
  • pgexercises: the Yugabyte clubdata sample (3 tables in a dedicated cd schema).
  • sportsdb: the Yugabyte sportsdb mirror (107 tables created; only generic infrastructure plus American football, baseball, basketball, and ice hockey carry data). Yugabyte USING lsm indexes are rewritten to btree at build time; an unused CREATE DOMAIN is dropped.
  • moma: schema authored in-repo (cockroach/scripts/moma/schema.sql, every column text); the CSV exports are read at build time and baked into the init script as batched INSERTs (CockroachDB's SQL client supports neither \copy nor COPY FROM '<file>'). Counts drift as MoMA refreshes its exports (recorded as floors).
  • geonames: schema authored in-repo (cockroach/scripts/geonames/schema.sql); the tab-separated export is shipped in the node's external-IO dir and bulk-loaded with IMPORT INTO ... DELIMITED DATA (the TSV form of CRDB's bulk path — the export has no quoting, so a double quote in a place name is a literal character). Counts drift as GeoNames rebuilds the dump daily (recorded as floors).
  • openflights: schema authored in-repo (cockroach/scripts/openflights/schema.sql, 3 tables); the published files are already RFC4180 CSV, so they are shipped to the node's external-IO dir and bulk-loaded with IMPORT INTO ... CSV DATA unchanged (nullif maps their \N to NULL). No foreign keys (routes deliberately keeps dangling airport/airline references). Counts drift as upstream refreshes the files (recorded as floors).
  • stackexchange-<site> (db = bare site name): per-table XML converted at build time by the shared cockroach stackexchange hook to CREATE TABLE + batched INSERTs + indexes (8 tables in public); Postgres' hook emits COPY instead, but CRDB's init-time stdin COPY is far slower for large blocks. Counts are recorded as floors. cooking is the largest.

⁠Datasets not ported to CockroachDB

The remaining datasets are either sourced from PostgreSQL-only upstreams or rely on PostgreSQL-specific features CockroachDB does not support faithfully:

  • pagila: not omitted but replaced — pagila is a port of Sakila to PostgreSQL with range-partitioned tables and a pgvector column; CockroachDB carries native Sakila instead (tag sakila, above), as MySQL and SQLite do.
  • adventureworks: the only maintained open port targets PostgreSQL; its build relies on a Python reformat plus multiple schemas and materialized views — too much PostgreSQL-specific machinery to load on CockroachDB without divergence.
  • airlines: not a dialect problem but a volume one — CockroachDB has jsonb, timestamptz and the range/array types the postgrespro demo⁠ uses (only point would need mapping), but its 10.7M rows are ten times the employees sample and would need the same CSV IMPORT INTO path with a ~500 MB /csv payload in the image; not shipped yet.
  • omdb: df7cb/omdb-postgresql⁠ relies on the tsm_system_rows extension (no CockroachDB equivalent), so a port would have to drop the upstream views.

⁠Custom images

Each image carries one dataset, selected with the DATASET build arg along with that dataset's sources (declared per tag in manifest.yml⁠). The simplest way to build a tag is through dave:

dave build -c cockroach -t dellstore

To add or change a CockroachDB dataset, declare its extractUrl, sqlFiles and any extras under a new tag in manifest.yml — the ETL Dockerfile⁠ reads them as build args. See docs/building.md⁠ for the full build instructions and how the build cache works.

Tag summary

Content type

Image

Digest

sha256:6240417ea…

Size

182.5 MB

Last updated

13 days ago

docker pull aa8y/cockroach-dataset