PostgreSQL with BDR B-Directional Replication in a docker.
Docker Image with PostgreSQL server with BDR support for database Bi-Directional replication. Based on CentOS with Supervisor.
User can specify if database should work as stand-alone
or master/slave
mode. Even though BDR is more master/master
solution we need to deploy first image which will create BDR setup inside of PostgreSQL. So for this purpose on run
we need to specify one image to be so called master.
Variable | Meaning |
---|---|
POSTGRES_PASSWORD |
Self explanatory |
POSTGRES_USER |
Self explanatory |
POSTGRES_DB |
Self explanatory |
POSTGRES_PORT |
Self explanatory |
MODE |
Mode in which this image shoudl work. Options: single/master/slave (default=single) |
MASTER_ADDRESS |
Address of master node |
MASTER_PORT |
Master node port |
SLAVE_PORT |
Slave node port |
docker run \
-d \
--name postgres \
-p 5432:5432 \
polinux/postgres-bdr
Use docker-compose.yml
exmple.
docker compose up
docker compose up master
docker compose up slave1
docker compose up slave2
docker build -t polinux/postgres-bdr .
Use docker command to see if all required containers are up and running:
$ docker ps
Check logs of postgres-bdr server container:
$ docker logs postgres-bdr
Sometimes you might just want to review how things are deployed inside a running container, you can do this by executing a bash shell through docker's exec command:
docker exec -ti postgres-bdr /bin/bash
History of an image and size of layers:
docker history --no-trunc=true polinux/postgres-bdr | tr -s ' ' | tail -n+2 | awk -F " ago " '{print $2}'
Przemyslaw Ozgo ([email protected])
This work is also inspired by agios's work on their docker images. Many thanks!