This image provides a complete PostgreSQL and repmgr environment for building high-availability database clusters. It's designed to simplify the setup of primary and standby nodes with automated failover capabilities, which is critical for production database environments.
Maintained by Sourcemation, this distribution is regularly updated to ensure it's current and secure. It is a focused container designed for easy integration into your existing infrastructure, providing a robust foundation for a resilient PostgreSQL setup.
repmgr continuously monitors the cluster and can automatically promote a standby node to primary in case of a failure.This image is intended for production environments where database uptime is critical. The setup requires starting at least two containers: one primary and one or more standbys.
docker network create my-network
The first node in the cluster must be started with the REPMGR_ROLE set to primary.
PRIMARY_NAME=primary
docker run -d --network my-network --name $PRIMARY_NAME \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
-e REPMGR_ROLE=primary \
-e REPMGR_USER=repmgr \
-e REPMGR_PASSWORD=repmgrpass \
-e REPMGR_DB=repmgr \
-e NODE_ID=1 \
-e NODE_NAME=$PRIMARY_NAME \
sourcemation/postgres-repmgr
A standby node clones its data from an upstream node (usually the primary). You must provide the node name of the primary in the REPMGR_UPSTREAM_NAME variable.
Start the standby container, pointing it to the primary:
STANDBY_NAME=standby
docker run -d --network my-network --name $STANDBY_NAME \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=mysecretpassword \
-e REPMGR_ROLE=standby \
-e REPMGR_USER=repmgr \
-e REPMGR_PASSWORD=repmgrpass \
-e REPMGR_DB=repmgr \
-e REPMGR_UPSTREAM_NAME=$PRIMARY_NAME \
-e NODE_ID=2 \
-e NODE_NAME=$STANDBY_NAME \
sourcemation/postgres-repmgr
You can check the health and status of your replication cluster by running the repmgr cluster show command inside any of the containers.
docker exec -it primary repmgr cluster show -f "/etc/repmgr/repmgr.conf"
This container uses the following environment variables for configuration:
| Variable | Description | Example |
|---|---|---|
POSTGRES_PASSWORD | Required. Sets the password for the main postgres superuser. | mysecretpassword |
REPMGR_ROLE | Required. Defines the node's role. Must be primary or standby. | primary |
REPMGR_USER | Required. The username repmgr will use to connect for replication. | repmgr |
REPMGR_PASSWORD | Required. The password for the repmgr user. | repmgrpass |
REPMGR_DB | Required. The database repmgr will use for its metadata. | repmgr |
REPMGR_UPSTREAM_NAME | Required for standbys. The node name of the primary node to clone from. | primary1 |
NODE_ID | Required. A unique integer ID for each node in the cluster. | 1 |
NODE_NAME | Required. A unique name for each node, often matching the container name. | primary-db |
The standard PostgreSQL port, 5432, is exposed by default for database connections.
Your contributions are valued! Feel free to suggest enhancements or request new images by opening an issue, or submit your own contributions via pull requests to the Sourcemation GitHub repository.
Disclaimer: The sourcemation/postgres-repmgr image is not affiliated with the PostgreSQL Global Development Group or EnterpriseDB. The respective entities own the trademarks mentioned in the offering. The sourcemation/postgres-repmgr image is a separate project and is maintained by Sourcemation.
A detailed risk analysis report of the image and its components can be found on the Sourcemation platform.
The base licenses for the solution are the PostgreSQL License and the GNU General Public License v3.0 for repmgr.
Content type
Image
Digest
sha256:167205d7a…
Size
103.6 MB
Last updated
4 days ago
docker pull sourcemation/postgres-repmgr