HUB
Sign inSign up
citus logo

upstreamyard/citus

By upstreamyard

•Updated 5 days ago

Citus distributed PostgreSQL: multi-arch, non-root, password auth, every Citus line, signed

Image
0

1.1K

upstreamyard/citus repository overview

upstreamyard logo

⁠Citus Docker image (Citus distributed PostgreSQL 14.3, 13.5, 12.1)

Running Citus in production? Email an engineer

Questions about this image? We build and test it, and we answer every email ourselves, usually within two days. Ask about upgrades, configuration, hardened or custom images, or anything else. A one-line question is fine: [email protected]⁠

Multi-arch (amd64, arm64) and signed Citus Docker image for every maintained Citus release line: 14.3 on PostgreSQL 16, 17 and 18, 13.5 on PostgreSQL 16 and 17, and 12.1 on PostgreSQL 15 and 16. Citus turns PostgreSQL into a distributed database: tables are sharded across worker nodes, and queries run in parallel. This image runs a Citus cluster without trust auth: nodes log in to each other with a password and TLS. Workers add themselves to the coordinator, so no extra manager container or Docker socket is needed. Online rebalancing works out of the box, and the container runs as non-root. It works with Docker, Docker Compose and Kubernetes, and is a drop-in alternative to the official citusdata/citus image, with the same tag names.

Community-maintained by upstreamyard. This is not an official Citus image. Citus is licensed under AGPL-3.0 (see Licences⁠).

RegistryImage
Docker Hubupstreamyard/citus
GitHub Container Registryghcr.io/upstreamyard/citus
TagCitusPostgreSQL
14.3.0, 14.3, 14, latest14.3.x, the newest line18
14.3.0-pg17, 14.3-pg17, 14-pg1714.3.x17
14.3.0-pg16, 14.3-pg16, 14-pg1614.3.x16
13.5.0, 13.5, 1313.5.x17
13.5.0-pg16, 13.5-pg16, 13-pg1613.5.x16
12.1.14, 12.1, 1212.1.x16
12.1.14-pg15, 12.1-pg15, 12-pg1512.1.x15
<citus>-pg<postgres>, e.g. 14.3.0-pg18.7fixed Citus versionfixed PostgreSQL minor version

Citus 13.5.0 doesn't compile against PostgreSQL 15.20 (Citus issue #8976⁠), so there is no 13.5.0-pg15; on PostgreSQL 15, use 12.1-pg15 until a fixed 13.5 release is out, which is then built automatically.

New Citus releases are built within 24 hours. Images are also rebuilt when the official PostgreSQL base image changes (new PostgreSQL minor release or Debian security fixes). Tags without a PostgreSQL minor version (14.3, 14.3-pg17) follow those rebuilds. Pin the PostgreSQL major version (14.3-pg18, not latest): a PostgreSQL major upgrade needs pg_upgrade, not just a new image.

⁠Why this Citus image

Compared with the official citusdata/citus image. We checked its Docker Hub tags and ran citusdata/citus:14.2.0 on 2026-11-29.

citusdata/citusupstreamyard/citus
Newest Citus 1414.2.0 (14.3.0 was released 2026-10-23)14.3.0
Older release linesnewest tags 13.2.0 and 12.1.613.5.0 and 12.1.14, the current releases
arm64 (Graviton, Apple silicon)only the floating alpine tag; versioned tags are amd64 onlyevery tag
Runs asstarts as root, then switches to UID 999UID 10001 from the start; read-only root filesystem works
Login between nodesPGPASSWORD in the environment or trust; its docker-compose.yml defaults to POSTGRES_HOST_AUTH_METHOD=trustpassword (scram-sha-256) from a generated password file, TLS 1.3
Adding workers in Composea membership-manager container with the Docker socket mountedworkers register themselves (CITUS_COORDINATOR_HOST)
Online rebalance and citus_drain_nodefail: logical decoding requires "wal_level" >= "logical"wal_level = logical by default; tested under writes
Extensionscitus, hll, topncitus, hll, topn, pgvector, pg_cron
Signed, SBOM, provenanceno (single-platform manifest without attestations or signature)cosign, SBOM, SLSA provenance

⁠At a glance

Port5432
Probehealthcheck (in PATH): pg_isready over TCP. Stays unhealthy while a new data directory is initialised
Requiresnothing for a single node. A cluster is one coordinator plus workers, all from this image, with the same POSTGRES_USER, POSTGRES_PASSWORD and POSTGRES_DB
StoragePostgreSQL 18: mount /var/lib/postgresql (data in /var/lib/postgresql/18/docker). PostgreSQL 15–17: mount /var/lib/postgresql/data
Configthe official PostgreSQL image's POSTGRES_* variables, plus the CITUS_* variables below
Runs asUID/GID 10001. With a read-only root filesystem, /var/run/postgresql and /tmp must be writable
Default authpassword required (POSTGRES_PASSWORD); trust only for connections from inside the container
ShutdownSIGINT (fast shutdown); docker stop takes about a second

AI agents and coding assistants: read AGENTS.md⁠ for deployment rules, and llms.txt⁠ for an index of all docs.

⁠Quick start: run Citus in Docker

A single node is a complete Citus database. The coordinator stores the shards itself until you add workers:

docker run -d --name citus -p 5432:5432 \
  -e POSTGRES_PASSWORD=change-me \
  -v citus-data:/var/lib/postgresql \
  upstreamyard/citus:14.3
docker exec -it citus psql -U postgres
CREATE TABLE events (tenant_id int, id bigserial, payload jsonb, PRIMARY KEY (tenant_id, id));
SELECT create_distributed_table('events', 'tenant_id');
SELECT citus_version();

The citus extension is created in POSTGRES_DB (default postgres) when the data directory is first created.

⁠Citus cluster with Docker Compose

docker-compose.yml⁠ starts a coordinator and two workers. The workers add themselves to the coordinator:

curl -fsSLO https://raw.githubusercontent.com/upstreamyard/citus/main/docker-compose.yml
export POSTGRES_PASSWORD=change-me   # every docker compose command needs it
docker compose up -d --wait
docker compose exec coordinator psql -U postgres -c 'SELECT * FROM citus_get_active_worker_nodes()'

Connect your application to the coordinator (localhost:5432). To add a worker, copy the worker-2 service with a new name, hostname and volume, start it, and spread the shards:

SELECT citus_rebalance_start();
SELECT citus_rebalance_wait();   -- or watch SELECT * FROM citus_rebalance_status();

Tested: a rebalance onto a third worker moved 10 shards in 16 seconds while a client kept inserting; all 400 concurrent inserts succeeded and no rows were lost.

Give every worker a fixed hostname: Citus stores node names in its metadata. With docker compose up --scale, a worker's hostname is its container ID, which changes when the container is recreated.

⁠Configuration

⁠Environment variables

All variables of the official PostgreSQL image work (POSTGRES_PASSWORD, POSTGRES_USER, POSTGRES_DB, POSTGRES_INITDB_ARGS, *_FILE, …). Use the same POSTGRES_USER, POSTGRES_PASSWORD and POSTGRES_DB on every node of a cluster.

VariableDefaultDescription
POSTGRES_PASSWORD– (required)Password of POSTGRES_USER. The nodes also use it to log in to each other
POSTGRES_PASSWORD_FILE–Read the password from a file, e.g. a mounted Secret
CITUS_COORDINATOR_HOST–Set on workers: the coordinator's host name. Once PostgreSQL is up, the worker adds itself with citus_add_node(), retrying until the coordinator answers. Safe on every restart
CITUS_COORDINATOR_PORT5432Coordinator port. Values that aren't a plain number (like Kubernetes' tcp://… service variables) are ignored
CITUS_NODE_HOSThostname -fName the coordinator and other workers use to reach this worker. Must stay the same across restarts
CITUS_NODE_PORTPGPORT or 5432Port other nodes use to reach this worker
CITUS_PGPASS_FILE–Extra lines for the password file (host:port:database:user:password), for other roles that run distributed queries. See below
PGPASSFILE/var/run/postgresql/.pgpassIf you set it, the container uses your file and doesn't write one

When a worker registers and the coordinator is still in the metadata as localhost (because it started single-node), the worker replaces that entry with CITUS_COORDINATOR_HOST, so the other nodes can reach the coordinator.

⁠Logins between nodes and application roles

Citus connects from one node to another as the role that runs the query. The container writes a password file with the POSTGRES_USER password, so the admin user works across nodes, over TLS (Citus turns on TLS with a self-signed certificate when the extension is created).

An application role (CREATE ROLE app LOGIN PASSWORD '…', run on the coordinator, is copied to the workers) also needs its password for these connections. Otherwise distributed queries fail with fe_sendauth: no password supplied. Mount a file on every node and point CITUS_PGPASS_FILE at it:

printf '*:*:*:app:app-password\n' > pgpass
docker run … -v "$PWD/pgpass:/run/secrets/pgpass:ro" -e CITUS_PGPASS_FILE=/run/secrets/pgpass upstreamyard/citus:14.3

Tested: Citus's pg_dist_authinfo table is not copied to the workers, so with queries from workers it would have to be filled on every node. The file works on all nodes at once.

⁠PostgreSQL settings

New data directories get shared_preload_libraries = 'citus' and wal_level = logical. Other settings: pass -c options, or use ALTER SYSTEM and restart.

docker run … upstreamyard/citus:14.3 postgres -c max_connections=300 -c shared_buffers=1GB

citus must stay first in shared_preload_libraries.

⁠Extensions
ExtensionUse
cituscreated automatically in POSTGRES_DB
hll, topnCREATE EXTENSION hll; on the coordinator; Citus creates it on the workers
vector (pgvector)CREATE EXTENSION vector; on the coordinator; vectors in distributed tables
pg_cronneeds preloading: postgres -c shared_preload_libraries=citus,pg_cron -c cron.database_name=postgres, then CREATE EXTENSION pg_cron;

⁠Removing a worker

Move its shards away first, then remove it. Tested on Kubernetes (16 shards, 50,000 rows: 12 seconds):

SELECT citus_drain_node('worker-3', 5432);
CALL citus_cleanup_orphaned_resources();
SELECT citus_remove_node('worker-3', 5432);

Then stop the worker and delete its volume. A worker started later on an old volume still has shard tables from before, and shard moves to it failed in our test with orphaned shard … could not be cleaned up.

⁠Kubernetes: run Citus on Kubernetes

examples/kubernetes/citus.yaml⁠ runs a coordinator and two workers as StatefulSets. Workers add themselves under their stable pod DNS names (citus-worker-0.citus-worker.<namespace>.svc.cluster.local):

kubectl create secret generic citus-auth --from-literal=password='change-me'
kubectl apply -f https://raw.githubusercontent.com/upstreamyard/citus/main/examples/kubernetes/citus.yaml
kubectl exec -it citus-coordinator-0 -- psql -U postgres -c 'SELECT * FROM citus_get_active_worker_nodes()'

Scale out with kubectl scale statefulset citus-worker --replicas=3, then SELECT citus_rebalance_start();. To scale in, follow Removing a worker⁠ for the highest-numbered pod, scale down, and delete its PVC (data-citus-worker-2).

We tested the manifest in kind (Kubernetes 1.34): scale out to three workers and a rebalance (16 s), drain and scale in, pod deletion (the worker came back with the same node ID), and adding a worker on a fresh PVC.

Rules for your own manifests:

  • Set enableServiceLinks: false. Otherwise a Service named citus-coordinator makes Kubernetes set CITUS_COORDINATOR_PORT=tcp://… in every pod. The image ignores such values, but other tools may not.
  • Workers need stable names: a StatefulSet with a headless Service.
  • runAsNonRoot, readOnlyRootFilesystem and dropping all capabilities work, with emptyDir volumes at /var/run/postgresql and /tmp.
  • Probes: exec: [healthcheck].

High availability: every Citus node is a single PostgreSQL server. This image doesn't add streaming replicas or automatic failover per node. If a worker's volume is lost, the shards on it are lost.

Not sure about your values or manifests? Tell us about your setup⁠ and we'll share what we found while testing.

⁠Migrating from the official citusdata/citus image

  • Tags: the same names (14.3.0, 14.3.0-pg17, …) select the same Citus and PostgreSQL versions.
  • Data: the same paths. The files must belong to UID 10001:
    docker run --rm --user 0 --entrypoint chown -v citus-data:/var/lib/postgresql upstreamyard/citus:14.3 -R 10001:10001 /var/lib/postgresql
    
    Then run ALTER EXTENSION citus UPDATE; on every node. Tested on a single node: a 14.2.0 data directory from the official image went from 14.2-1 to 14.3-1, all rows kept.
  • wal_level: existing data directories keep replica. For online shard moves, run ALTER SYSTEM SET wal_level = logical; and restart.
  • Inter-node auth: drop PGPASSWORD and POSTGRES_HOST_AUTH_METHOD=trust. The password file handles it.
  • Membership manager: replace it with CITUS_COORDINATOR_HOST on the workers.

⁠FAQ

How do I run Citus in Docker? docker run -e POSTGRES_PASSWORD=change-me -p 5432:5432 upstreamyard/citus:14.3; see the quick start⁠.

How do I set up a multi-node Citus cluster? Use Docker Compose⁠ or the Kubernetes manifest⁠: set CITUS_COORDINATOR_HOST on each worker.

Is Citus a fork of PostgreSQL? No, it's a PostgreSQL extension. This image is the official PostgreSQL image with Citus added, so PostgreSQL tools and drivers work unchanged.

Which version should I use? Citus 14.3 on PostgreSQL 18 for new clusters. Existing clusters: stay on your PostgreSQL major version and take the newest Citus line built for it (13.5 on PostgreSQL 16 or 17, 12.1 on PostgreSQL 15).

Is there an arm64 Citus image? Yes, every tag is built for amd64 and arm64.

Why do distributed queries fail with fe_sendauth: no password supplied? Citus connects to the workers as the querying role, and that role's password isn't known on the node. See application roles⁠.

Why does citus_rebalance_start() or citus_drain_node() fail with logical decoding requires "wal_level" >= "logical"? The data directory was created with another image. Run ALTER SYSTEM SET wal_level = logical; and restart.

Why does a rebalance hang with not enough empty space on node if the shard is moved? Citus keeps 10% of the disk free and retries the move. Free up space, or lower citus.desired_percent_disk_available_after_move.

Does it send usage statistics? No. Citus's anonymous statistics collection is off in this build (citus.enable_statistics_collection = off).

⁠Verifying images

Images are signed keylessly with cosign⁠ and include an SBOM and SLSA provenance:

cosign verify upstreamyard/citus:14.3 \
  --certificate-identity-regexp '^https://github.com/upstreamyard/citus/' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

docker buildx imagetools inspect upstreamyard/citus:14.3 --format '{{ json .SBOM }}'

⁠How it's built

.github/workflows/build.yml⁠ finds the newest release of each maintained Citus line and reads the PostgreSQL versions it supports from its configure.ac. For each pair, it builds the Dockerfile⁠ for amd64 and arm64.

  • Base: the official postgres:<major>-trixie image, pinned by digest and recorded in the org.opencontainers.image.base.digest label. A new base digest triggers a rebuild.
  • Built from source: Citus at its release tag; TopN 2.7.1 from its release archive, pinned by SHA-256.
  • Added from the PostgreSQL apt repository: hll, pgvector, pg_cron; tini as PID 1.
  • Changed:
    • the postgres user is UID/GID 10001 instead of 999;
    • shared_preload_libraries = 'citus' and wal_level = logical for new data directories;
    • a password file for logins between nodes;
    • optional worker registration.
  • Testing: before publishing, scripts/smoke-test.sh⁠ starts a coordinator and self-registering workers (amd64) and checks:
    • distributed and reference tables, and queries from a worker;
    • the extensions, and TLS between nodes;
    • an application role via CITUS_PGPASS_FILE;
    • an online rebalance onto a new worker under writes;
    • restart and clean shutdown.

⁠Licences

ComponentLicenceLicence text in the imageSource code
CitusAGPL-3.0/licenses/citus/citusdata/citus⁠ at tag v<version>
TopNAGPL-3.0/licenses/topn/citusdata/postgresql-topn⁠
PostgreSQL, hll, pgvector, pg_cron, Debian packagesPostgreSQL, Apache-2.0 and others/usr/share/doc/*/copyrightPostgreSQL apt repository and Debian source archives
Our packaging (Dockerfile, scripts)Apache-2.0–this repository

⁠Support

⁠Talk to the people who build this image

Email [email protected]⁠. The maintainers of this image read and answer it.

You can write to us about:

  • setup: configuration, connecting Citus to your other services, Kubernetes manifests;
  • problems: a failing upgrade, a container that won't start, errors you can't explain;
  • security: hardened or minimal images, custom base images, CVEs in the image.

Not sure if your question fits? Send it anyway. Two sentences about what you run and where you're stuck are enough.

⁠Bugs

Issues with the image: open an issue here⁠. Questions about using Citus: Citus documentation⁠ and Citus on GitHub⁠.

Tag summary
Recent tags
Content type
Image
Digest
sha256:13b47afa1…
Size
170.7 MB
Last updated
5 days ago
docker pull upstreamyard/citus:latest