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
| Port | Protocol | Clients |
|---|---|---|
| 5432 | PostgreSQL | psql, libpq, JDBC, Npgsql, psycopg, sqlx, ORMs |
| 61170 | native | rasterizeddb_client, RasterizedDB Studio |
| 3306 | MySQL / MariaDB | mysql, mariadb, MySQL drivers |
| 1433 | SQL Server (TDS) | sqlcmd, Microsoft.Data.SqlClient, EF Core |
| 6379 | Redis | redis-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,mysqlormariadb,sqlcmd,redis-cli.
What to edit
- Copy
.env.exampleto.envand setRASTERIZEDDB_PG_PASSWORD. - Optional: remove the flags and ports of any protocol you do not need, in
compose.yaml. - Optional: tighten TLS. The defaults:
| Flag | Default | Notes |
|---|---|---|
--pg-tls | require | prefer also accepts cleartext |
--mysql-tls | prefer | require refuses cleartext. A first password login over TCP needs TLS either way. |
--mssql-tls | prefer | Under prefer, a client that declines encryption is served without it and sends its password in the clear. Set require to refuse such clients. |
--kv-tls | off | on 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
docker compose up -d
docker compose psCheck that it works
Set the password in your shell for the commands below:
export PW='the password from .env'PostgreSQL protocol: make a table to read from the others.
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.
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:
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:
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 greetingOK
"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
docker compose down # keeps the data volume
docker compose down -v # deletes the data volume tooLimits
- 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
# 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:# 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