What is MariaDB Replication?
This is classic asynchronous MariaDB replication: one primary accepts writes and streams its binary log to a read-only replica. It is the standard topology for read-scaling (send reads to the replica) and for keeping a hot standby copy of your data.
The official MariaDB image wires it from environment variables - the primary creates the replication user automatically, and the replica configures itself against the primary and starts replicating on first boot, so there are no init scripts. The replica is started read-only.
Replication is asynchronous: the replica can lag slightly under load, and a failed primary does not auto-promote (that is a manual or external-tooling step). For synchronous, automatic multi-primary HA, use mariadb-galera.
What you get
- Writable primary + read-only replica
- Binlog replication wired from environment variables
- No init scripts - the image configures the replica
- Read-scaling and hot-standby topology
- Both nodes internal-only
- GPLv2
How it runs on Lyngbak
| Service | Role | Public |
|---|---|---|
mariadb-primary | writable primary (:3306) | no (internal) |
mariadb-replica | read-only replica (:3306) | no (internal) |
Before you deploy
MARIADB_ROOT_PASSWORDroot password (same on both nodes)
MARIADB_PASSWORDapp user password
MARIADB_REPLICATION_PASSWORDreplication account password
Sizing and billing
1 GiB per node suits typical workloads. The replica holds a full copy of the data, so size both volumes the same. Asynchronous - expect small replica lag under load.
A resource is a flat monthly price, with RAM and disk add-ons when the stack needs a little more than a tier, and room for your own apps on a larger one. On Usage Billing each service takes the smallest size that fits it and is billed by the second it runs, so a stopped stack stops costing CPU and RAM. Its 19.53 GiB of volumes cost $0.15 per GiB a month ($2.93/mo) for as long as they exist. One workspace can use both. See pricing
Compared with the managed service
| Service | Plan | Price | Includes |
|---|---|---|---|
| AWS RDS | primary + read replica | $30/mo | two smallest instances/mo + storage |
A managed read replica is a second billed instance; here the primary + replica is one stack, billed for the compute it reserves. Prices from each vendor's pricing page, June 2026.
Run it locally first
The same compose file runs with plain Docker Compose. Clone the template source, copy .env.example to .env, and run docker compose up -d.
Questions
What is this good for?
Read-scaling (route read-heavy queries to the replica to offload the primary) and keeping a hot standby copy of your database. It is the most common MySQL/MariaDB replication setup.
Does it fail over automatically?
No. Asynchronous replication does not auto-promote the replica if the primary dies - promotion is a manual or tooling-driven step. For automatic failover use mariadb-galera (synchronous multi-primary).
How is the replica set up?
Automatically. The official image creates the replication user on the primary and, on the replica, configures replication against MARIADB_MASTER_HOST and starts it on first boot - no scripts to run.