NEW RasterizedDB 1.1.0 is out: sharding and the gateway, the message broker, roles and row-level security, compression, .NET on NuGet, and the enterprise edition. What's new ›
DOCS / DOCKER RECIPES / SINGLE CONTAINER

Single container

Run the RasterizedDB server in one container with docker run, its data on a named volume. Use it to try the server or to run one instance on a host without Compose. The scripts below do the same thing on Linux and macOS (run.sh) and on Windows (run.ps1).

What you get

  • The server on the PostgreSQL protocol (port 5432) and the native protocol (port 61170, used by rasterizeddb_client and RasterizedDB Studio), both on one catalogue.
  • A superuser role named rasterized with the password you choose.
  • Data on the volume rasterizeddb-data, kept across restarts and container rebuilds.
  • A restart policy (unless-stopped) and 60 seconds for a clean shutdown on docker stop.
  • Ports published on 127.0.0.1 only, until you choose otherwise.

Prerequisites

  • Docker Engine or Docker Desktop.
  • On x86-64, a CPU with AVX2 (x86-64-v3). The linux/arm64 image has no such requirement.
  • To check the result: psql (any recent PostgreSQL client), or the postgres:17 image, which contains it.

The image

The images are published on Docker Hub as milendenev/rasterizeddb and on GitHub as ghcr.io/milen-denev/rasterizeddb, with the same tags in both, for linux/amd64 and linux/arm64.

TagBase
1.1.0, 1.1, 1, latest, 1.1.0-ubuntu24.04, 1.1-ubuntu24.04, ubuntu24.04Ubuntu 24.04
1.1.0-ubuntu26.04, 1.1-ubuntu26.04, ubuntu26.04Ubuntu 26.04
1.1.0-alpine, 1.1-alpine, alpineAlpine, with a static build of the server
1.1.0-rustfs, 1.1-rustfs, rustfsthe server with RustFS object storage beside it (see RustFS all-in-one)

What every image does:

Commandrasterizeddb --location /var/lib/rasterizeddb --protocol both --pg-addr 0.0.0.0 --rdb-addr 0.0.0.0. Anything after the image name is added to it.
Data/var/lib/rasterizeddb, declared as a volume
Ports5432 (PostgreSQL protocol), 61170 (native protocol)
Useruid and gid 10001, in every variant, so a volume moves between them
PasswordRASTERIZEDDB_PG_PASSWORD, the password of the role rasterized
Stop signalSIGTERM, a clean shutdown

The scripts pin 1.1.0. Pin a full version in anything you deploy, so a restart never changes the version under you. See Upgrading.

What to edit

Set the password in the environment before you run a script. The scripts read it from there, so it never appears on the docker command line.

Settingrun.sh (environment)run.ps1 (parameter)Default
Password, requiredRASTERIZEDDB_PG_PASSWORD$env:RASTERIZEDDB_PG_PASSWORDnone
ImageIMAGE-Imagemilendenev/rasterizeddb:1.1.0
Container nameNAME-Namerasterizeddb
Data volumeVOLUME-Volumerasterizeddb-data
Host address for the portsBIND-Bind127.0.0.1

Set BIND=0.0.0.0 (or -Bind 0.0.0.0) to accept connections from other machines. Read Security before you do.

The password is used once, on the first start, to create the role rasterized. Changing the variable later does nothing. To change the password of a running server, connect and run:

sql
ALTER ROLE rasterized PASSWORD 'the-new-password';

Run it

Linux and macOS:

sh
export RASTERIZEDDB_PG_PASSWORD='a-long-random-password'
./run.sh

Windows:

powershell
$env:RASTERIZEDDB_PG_PASSWORD = 'a-long-random-password'
.\run.ps1

Server flags go after the script name (run.sh) or in -ServerArgs (run.ps1), and are added to the image's own. For example, more log output and a lower connection limit:

sh
./run.sh --log-level info --max-connections 200
powershell
.\run.ps1 -ServerArgs '--log-level', 'info', '--max-connections', '200'

docker run --rm milendenev/rasterizeddb:1.1.0 --help lists every server flag. See Configuration for what they do.

Check that it works

sh
psql "host=127.0.0.1 port=5432 user=rasterized dbname=postgres sslmode=require" -c "SELECT 1 AS ok"
text
 ok
----
  1
(1 row)

The PostgreSQL protocol requires TLS by default, with a self-signed certificate made at start-up, so clients connect with sslmode=require. To use your own certificate, see Compose with TLS.

Without psql on the host, run it from the postgres:17 image inside the server's network namespace:

sh
docker run --rm -it --network container:rasterizeddb -e PGPASSWORD="$RASTERIZEDDB_PG_PASSWORD" postgres:17 \
  psql "host=127.0.0.1 port=5432 user=rasterized dbname=postgres sslmode=require"

If the container is not running, read why:

sh
docker logs rasterizeddb

A container started without a password exits straight away and says so in its log: the server refuses to listen beyond loopback without one.

Stop and clean up

Stop and start again (the data stays):

sh
docker stop -t 60 rasterizeddb
docker start rasterizeddb

Remove the container. The data stays on the volume, and running the script again picks it up:

sh
docker rm -f rasterizeddb

Remove the data too. This deletes the database for good:

sh
docker rm -f rasterizeddb
docker volume rm rasterizeddb-data

Limits

  • This recipe has no healthcheck, so nothing reports when the server is ready. Compose basic adds one.
  • A bind-mounted host directory works instead of a volume only if uid 10001 can write to it.
  • docker stop without -t gives the server 10 seconds. The scripts set 60 for the container, so plain docker stop uses that.

The files

run.sh · Linux and macOS (Bash)DOWNLOAD ↓
#!/usr/bin/env bash
# Starts one RasterizedDB container with its data on a named volume.
#
#   export RASTERIZEDDB_PG_PASSWORD='a-long-random-password'
#   ./run.sh                         # default flags
#   ./run.sh --log-level warn        # anything after the script name goes to the server
#
# Settings (environment variables, all optional except the password):
#   IMAGE   image and tag            (default milendenev/rasterizeddb:1.1.0)
#   NAME    container name           (default rasterizeddb)
#   VOLUME  data volume              (default rasterizeddb-data)
#   BIND    host address to publish  (default 127.0.0.1; 0.0.0.0 for every interface)
set -euo pipefail

IMAGE="${IMAGE:-milendenev/rasterizeddb:1.1.0}"
NAME="${NAME:-rasterizeddb}"
VOLUME="${VOLUME:-rasterizeddb-data}"
BIND="${BIND:-127.0.0.1}"

if [ -z "${RASTERIZEDDB_PG_PASSWORD:-}" ]; then
  echo "Set RASTERIZEDDB_PG_PASSWORD first: it becomes the password of the role 'rasterized'." >&2
  exit 1
fi

docker volume create "$VOLUME" >/dev/null

# -e RASTERIZEDDB_PG_PASSWORD (no value) copies it from this shell, so the
# password is not written on the docker command line.
docker run -d \
  --name "$NAME" \
  --restart unless-stopped \
  --stop-timeout 60 \
  -e RASTERIZEDDB_PG_PASSWORD \
  -p "$BIND:5432:5432" \
  -p "$BIND:61170:61170" \
  -v "$VOLUME:/var/lib/rasterizeddb" \
  "$IMAGE" "$@"

echo "Started $NAME from $IMAGE."
echo "Connect: psql \"host=127.0.0.1 port=5432 user=rasterized dbname=postgres sslmode=require\""
run.ps1 · Windows (PowerShell)DOWNLOAD ↓
# Starts one RasterizedDB container with its data on a named volume.
#
#   $env:RASTERIZEDDB_PG_PASSWORD = 'a-long-random-password'
#   .\run.ps1                          # default flags
#   .\run.ps1 -ServerArgs '--log-level', 'warn'   # server flags, after the image's own
#   .\run.ps1 -Bind 0.0.0.0            # publish on every interface
param(
    [string] $Image = 'milendenev/rasterizeddb:1.1.0',
    [string] $Name = 'rasterizeddb',
    [string] $Volume = 'rasterizeddb-data',
    [string] $Bind = '127.0.0.1',
    [Parameter(ValueFromRemainingArguments = $true)]
    [string[]] $ServerArgs
)
$ErrorActionPreference = 'Stop'

if (-not $env:RASTERIZEDDB_PG_PASSWORD) {
    throw "Set `$env:RASTERIZEDDB_PG_PASSWORD first: it becomes the password of the role 'rasterized'."
}

docker volume create $Volume | Out-Null
if ($LASTEXITCODE -ne 0) { throw "docker volume create $Volume failed" }

# -e RASTERIZEDDB_PG_PASSWORD (no value) copies it from this session, so the
# password is not written on the docker command line.
$runArgs = @(
    'run', '-d',
    '--name', $Name,
    '--restart', 'unless-stopped',
    '--stop-timeout', '60',
    '-e', 'RASTERIZEDDB_PG_PASSWORD',
    '-p', "${Bind}:5432:5432",
    '-p', "${Bind}:61170:61170",
    '-v', "${Volume}:/var/lib/rasterizeddb",
    $Image
)
if ($ServerArgs) { $runArgs += $ServerArgs }

docker @runArgs
if ($LASTEXITCODE -ne 0) { throw "docker run failed" }

Write-Host "Started $Name from $Image."
Write-Host 'Connect: psql "host=127.0.0.1 port=5432 user=rasterized dbname=postgres sslmode=require"'
✓ page rendered in 113 µs axum + tera + htmx · no other javascript