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 / ALL PROTOCOLS

All protocols

One server that PostgreSQL, MySQL, SQL Server and Redis clients can all reach, plus the native protocol, on the same databases and roles. Use it to try existing tools and applications against RasterizedDB, or to serve applications written for different databases from one server.

What you get

PortProtocolClients
5432PostgreSQLpsql, libpq, JDBC, Npgsql, psycopg, sqlx, ORMs
61170nativerasterizeddb_client, RasterizedDB Studio
3306MySQL / MariaDBmysql, mariadb, MySQL drivers
1433SQL Server (TDS)sqlcmd, Microsoft.Data.SqlClient, EF Core
6379Redisredis-cli, any Redis client library

All five log in as the same roles. The role rasterized gets the password from .env. Ports are published on 127.0.0.1.

The MySQL, SQL Server and Redis listeners are off unless their port flag is given. compose.yaml gives all three and binds them to the container's interfaces with the --*-addr 0.0.0.0 flags. Each one defaults to 127.0.0.1, which a client outside the container cannot reach.

Prerequisites

  • Docker with the Compose plugin.
  • The clients you want to try: psql, mysql or mariadb, sqlcmd, redis-cli.

What to edit

  1. Copy .env.example to .env and set RASTERIZEDDB_PG_PASSWORD.
  2. Optional: remove the flags and ports of any protocol you do not need, in compose.yaml.
  3. Optional: tighten TLS. The defaults:
FlagDefaultNotes
--pg-tlsrequireprefer also accepts cleartext
--mysql-tlspreferrequire refuses cleartext. A first password login over TCP needs TLS either way.
--mssql-tlspreferUnder prefer, a client that declines encryption is served without it and sends its password in the clear. Set require to refuse such clients.
--kv-tlsoffon makes every Redis client use TLS (redis-cli --tls)

Without certificates of your own, each TLS listener uses a self-signed certificate made at start-up. To give them a real one, add --pg-cert and --pg-key as in Compose with TLS. The MySQL, SQL Server and Redis listeners use the same files unless given --mysql-cert/--mysql-key or --mssql-cert/--mssql-key.

Run it

sh
docker compose up -d
docker compose ps

Check that it works

Set the password in your shell for the commands below:

sh
export PW='the password from .env'

PostgreSQL protocol: make a table to read from the others.

sh
PGPASSWORD="$PW" psql "host=127.0.0.1 port=5432 user=rasterized dbname=postgres sslmode=require" \
  -c "CREATE TABLE greetings (id INT PRIMARY KEY, message TEXT)" \
  -c "INSERT INTO greetings VALUES (1, 'hello from postgres')"

MySQL protocol. Use 127.0.0.1, not localhost: the mysql client takes localhost to mean a local socket file.

sh
mysql -h 127.0.0.1 -P 3306 -u rasterized -p"$PW" --ssl-mode=REQUIRED -e "SELECT id, message FROM greetings"

The mariadb client takes --ssl instead of --ssl-mode=REQUIRED.

SQL Server protocol. -C trusts the self-signed certificate:

sh
sqlcmd -S 127.0.0.1,1433 -U rasterized -P "$PW" -C -Q "SELECT id, message FROM greetings"

Redis protocol. REDISCLI_AUTH gives redis-cli the password without putting it on the command line. A password without a user name is checked as the role rasterized:

sh
REDISCLI_AUTH="$PW" redis-cli -h 127.0.0.1 -p 6379 SET greeting hello
REDISCLI_AUTH="$PW" redis-cli -h 127.0.0.1 -p 6379 GET greeting
text
OK
"hello"

Native protocol: point RasterizedDB Studio or rasterizeddb_client at 127.0.0.1:61170 with user rasterized and the same password. See Studio and Connecting.

Stop and clean up

sh
docker compose down        # keeps the data volume
docker compose down -v     # deletes the data volume too

Limits

  • Each protocol translates its own SQL dialect onto one engine. What translates and what does not is in MySQL and SQL Server.
  • The Redis port serves the store of the default database (postgres). See KV cache.
  • SQL Server clients log in with SQL Server authentication (user name and password) only.

The files

compose.yaml · Docker ComposeDOWNLOAD ↓
# RasterizedDB serving every client protocol at once, on one catalogue:
# PostgreSQL, native, MySQL, SQL Server (TDS) and Redis. Copy .env.example
# to .env first.
name: rasterizeddb-protocols

services:
  rasterizeddb:
    image: ${RASTERIZEDDB_IMAGE:-milendenev/rasterizeddb:1.1.0}
    environment:
      RASTERIZEDDB_PG_PASSWORD: ${RASTERIZEDDB_PG_PASSWORD:?set RASTERIZEDDB_PG_PASSWORD in .env}
    command:
      # MySQL / MariaDB clients
      - --mysql-port
      - "3306"
      - --mysql-addr
      - 0.0.0.0
      # SQL Server clients (TDS)
      - --mssql-port
      - "1433"
      - --mssql-addr
      - 0.0.0.0
      # Redis clients
      - --kv-port
      - "6379"
      - --kv-addr
      - 0.0.0.0
      - --log-level
      - warn
    ports:
      - "127.0.0.1:5432:5432"   # PostgreSQL
      - "127.0.0.1:61170:61170" # native (rasterizeddb_client, Studio)
      - "127.0.0.1:3306:3306"   # MySQL
      - "127.0.0.1:1433:1433"   # SQL Server
      - "127.0.0.1:6379:6379"   # Redis
    volumes:
      - data:/var/lib/rasterizeddb
    restart: unless-stopped
    stop_grace_period: 60s
    healthcheck:
      test: ["CMD", "bash", "-c", "exec 3<>/dev/tcp/127.0.0.1/5432"]
      interval: 10s
      timeout: 5s
      retries: 6
      start_period: 30s

volumes:
  data:
.env.example · Environment fileDOWNLOAD ↓
# Copy to .env next to compose.yaml and change the password.

# The password of the role `rasterized`, used on the first start only.
RASTERIZEDDB_PG_PASSWORD=change-me-to-a-long-random-password

# The image and tag. Pin a full version.
RASTERIZEDDB_IMAGE=milendenev/rasterizeddb:1.1.0
✓ page rendered in 109 µs axum + tera + htmx · no other javascript