专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像 官方专业版轩辕镜像 官方专业版官方专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题
其他
关于我们网站地图

官方QQ群: 1072982923

postdock/postgres Docker 镜像 - 轩辕镜像 | Docker 镜像高效稳定拉取服务

热门搜索:openclaw🔥nginx🔥redis🔥mysqlopenjdkcursorweb2apimemgraphzabbixetcdubuntucorednsjdk
postgres
postdock/postgres
自动构建
postdock
PostgreSQL server image, can work in master or slave mode (part of PostDock solution)
14 次收藏下载次数: 0状态:自动构建维护者:postdock仓库类型:镜像最近更新:6 年前
轩辕镜像,让镜像更快,让人生更轻。点击查看
镜像简介版本下载
轩辕镜像,让镜像更快,让人生更轻。点击查看

PostDock - Postgres + Docker

PostgreSQL cluster with High Availability and Self Healing features for any cloud and docker environment (Amazon, Google Cloud, Kubernetes, Docker Compose, Docker Swarm, Apache Mesos)

!Formula

![Build Status]([***]

  • Info
    • Features
    • What's in the box
    • Docker images tags convention
      • Repositories
  • Start cluster with docker-compose
  • Start cluster in Kubernetes
  • Adaptive mode
  • SSH access
  • Replication slots
  • Configuring the cluster
    • Postgres
    • Pgpool
    • Barman
    • Other configurations
  • Extended version of postgres
  • Backups and recovery
  • Health-checks
  • Useful commands
  • Publications
  • Scenarios
  • How to contribute
  • FAQ
  • Documentation and manuals

Info

Features
  • High Availability
  • Self Healing and Automated Reconstruction
  • Split Brain) Tolerance
  • Eventually/Partially Strict/Strict Consistency modes
  • Reads Load Balancing and Connection Pool
  • Incremental backup (with optional zero data loss, RPO=0)
  • Semi-automated Point In Time Recovery Procedure
  • Monitoring exporters for all the components(nodes, ***s, backup)
What's in the box

This project includes:

  • Dockerfiles for postgresql cluster and backup system
    • postgresql
    • pgpool
    • barman
  • Examples of usage(suitable for production environment as architecture has fault protection with auto failover)
    • example of docker-compose file to start this cluster.
    • directory k8s contains information for building this cluster in Kubernetes
Docker images tags convention

Taking into account that PostDock project itself has versioning schema, all docker images produced by the repository have schema - postdock/<component>:<postdock_version>-<component><component_version>-<sub_component><sub_component_version>[...], where:

  • <postdock_version> - semantic version without bug-fix component (can be 1.1, 1.2, ...)
  • <component>, <component_version> - depends on component:
    • postgres,postgres-extended - major and minor version without dot in between(can be 95, 96, 10, 11, ...)
    • pgpool - major and minor version of component without dot in between(can be 33, 36, 37, ...)
    • barman - major version only (can be 23, 24, ...)
  • <sub_component>, <sub_component_version> - depends on component:
    • for postgres - repmgr can be 32, 40, ...
    • for barman - postgres can be 96, 10, 11, ...
    • for pgpool - postgres can be 96, 10, 11, ...

Aliases are available (not recommended to use for production):

  • postdock/<component>:latest-<component><component_version>[-<sub_component><sub_component_version>[...]] - refers to the latest release of the postdock, certain version of the component, certain version of the sub-components(e.g. postdock/postgres:latest-postgres101-repmgr32,postdock/postgres:latest-barman23-postgres101)
  • postdock/<component>:latest - refers to the latest release of the postdock and the latest versions of all the components and sub-components (e.g. postdock/postgres:latest)
  • postdock/<component>:edge - refers to build of postdock from master with the latest version the component, and all sub-components (e.g. postdock/postgres:edge)
Repositories

All available tags (versions and combinations of it) are listed in respective docker-hub repositories:

  • Postgres
  • Pgpool
  • Barman

Start cluster with docker-compose

To start cluster run it as normal docker-compose application docker-compose -f ./docker-compose/latest.yml up -d pgmaster pgslave1 pgslave2 pgslave3 pgslave4 pgpool backup

Schema of the example cluster:

pgmaster (primary node1)  --|
|- pgslave1 (node2)       --|
|  |- pgslave2 (node3)    --|----pgpool (master_slave_mode stream)
|- pgslave3 (node4)       --|
   |- pgslave4 (node5)    --|

Each postgres node (pgmaster, pgslaveX) is managed by repmgr/repmgrd. It allows to use automatic failover and check cluster status.

Please check comments for each ENV variable in ./docker-compose/latest.yml file to understand parameter for each cluster node

Start cluster in Kubernetes

Using Helm (recomended for production)

You can install PostDock with Helm package manager check the README.md of the package for more information

Simple (NOT recomended for production)

To make it easier repository contains services' objects under k8s dir. Setup PostgreSQL cluster following the steps in the example. It also has information how to check cluster state

Configuring the cluster

You can configure any node of the cluster(postgres.conf) or pgpool(pgpool.conf) with ENV variable CONFIGS (format: variable1:value1[,variable2:value2[,...]], you can redefine delimiter and assignment symbols by using variables CONFIGS_DELIMITER_SYMBOL, CONFIGS_ASSIGNMENT_SYMBOL). Also see the Dockerfiles and docker-compose/latest.yml files in the root of the repository to understand all available and used configurations!

Postgres

For the rest - you better follow the advise and look into the src/Postgres-latest.Dockerfile file - it full of comments :)

Pgpool

The most important part to configure in Pgpool (apart of general CONFIGS) is backends and users which could access these backends. You can configure backends with ENV variable. You can find good example of setting up pgpool in docker-compose/latest.yml file:

DB_USERS: monkey_user:monkey_pass # in format user:password[,user:password[...]]
BACKENDS: "0:pgmaster:5432:1:/var/lib/postgresql/data:ALLOW_TO_FAILOVER,1:pgslave1::::,3:pgslave3::::,2:pgslave2::::" #,4:pgslaveDOES_NOT_EXIST::::
            # in format num:host:port:weight:data_directory:flag[,...]
            # defaults:
            #   port: 5432
            #   weight: 1
            #   data_directory: /var/lib/postgresql/data
            #   flag: ALLOW_TO_FAILOVER
REQUIRE_MIN_BACKENDS: 3 # minimal number of backends to start pgpool (some might be unreachable)
Barman

The most important part for barman is to setup access variables. Example can be found in docker-compose/latest.yml file:

REPLICATION_USER: replication_user # default is replication_user
REPLICATION_PASSWORD: replication_pass # default is replication_pass
REPLICATION_HOST: pgmaster
POSTGRES_PASSWORD: monkey_pass
POSTGRES_USER: monkey_user
POSTGRES_DB: monkey_db
Other configurations

See the Dockerfiles and docker-compose/latest.yml files in the root of the repository to understand all available and used configurations!

Adaptive mode

'Adaptive mode' means that node will be able to decide if instead of acting as a master on it's start or switch to standby role. That possible if you pass PARTNER_NODES (comma separated list of nodes in the cluster on the same level). So every time container starts it will check if it was master before and if there is no new master around (from the list PARTNER_NODES), otherwise it will start as a new standby node with upstream = new master in the cluster.

Keep in mind: this feature does not work for cascade replication and you should not pass PARTNER_NODES to nodes on second level of the cluster. Instead of it just make sure that all nodes on the first level are running, so after restart any node from second level will be able to follow initial upstream from the first level. That also can mean - replication from second level potentially can connect to root master... Well not a big deal if you've decided to go with adaptive mode. But nevertheless you are able to play with NODE_PRIORITY environment variable and make sure entry point for second level of replication will never be elected as a new root master

SSH access

If you have need to organize your cluster with some tricky logic or less problematic cross checks. You can enable SSH server on each node. Just set ENV variable SSH_ENABLE=1 (disabled by default) in all containers (including pgpool and barman). That will allow you to connect from any to any node by simple command under postgres user: gosu postgres ssh {NODE NETWORK NAME}

You also will have to set identical ssh keys to all containers. For that you need to mount files with your keys in paths /tmp/.ssh/keys/id_rsa, /tmp/.ssh/keys/id_rsa.pub.

Replication slots

If you want to disable the feature of Postgres>=9.4 - replication slots simply set ENV variable USE_REPLICATION_SLOTS=0 (enabled by default). So cluster will rely only on Postgres configuration wal_keep_segments (500 by default). You also should remember that default number for configuration max_replication_slots is 5. You can change it (as any other configuration) with ENV variable CONFIGS.

Extended version of postgres

Component postgres-extended from the section Docker images tags convention should be used if you want to have postgres with extensions and libraries. Each directory here represents extension included in the image.

Backups and recovery

Barman is used to provide real-time backups and Point In Time Recovery (PITR).. This image requires connection information(host, port) and 2 sets of credentials, as you can see from the Dockerfile:

  • Replication credentials
  • Postgres admin credentials

Barman acts as warm standby and stream WAL from source. Additionaly it periodicaly takes remote physical backups using pg_basebackup. This allows to make PITR in reasonable time within window of specified size, because you only have to replay WAL from lastest base backup. Barman automatically deletes old backups and WAL according to retetion policy. Backup source is static — pgmaster node. In case of master failover, backuping will continue from standby server Whole backup procedure is performed remotely, but for recovery SSH access is required.

Before using in production read following documentation:

  • [***]
  • [***]

For Disaster Recovery process see RECOVERY.md

Barman exposes several metrics on :8080/metrics for more information see Barman docs

Health-checks

To make sure you cluster works as expected without 'split-brain' or other issues, you have to setup health-checks and stop container if any health-check returns non-zero result. That is really useful when you use Kubernetes which has livenessProbe (check how to use it in the example)

  • Postgres containers:
    • /usr/local/bin/cluster/healthcheck/is_major_master.sh - detect if node acts as a 'false'-master and there is another master - with more standbys
  • Pgpool
    • /usr/local/bin/pgpool/has_enough_backends.sh [REQUIRED_NUM_OF_BACKENDS, default=$REQUIRE_MIN_BACKENDS] - check if there are enough backend behind pgpool
    • /usr/local/bin/pgpool/has_write_node.sh - check if one of the backend can be used as a master with write access

Useful commands

  • Get map of current cluster(on any postgres node):
    • gosu postgres repmgr cluster show - tries to connect to all nodes on request ignore status of node in $(get_repmgr_schema).$REPMGR_NODES_TABLE
    • gosu postgres psql $REPLICATION_DB -c "SELECT * FROM $(get_repmgr_schema).$REPMGR_NODES_TABLE" - just select data from tables
  • Get pgpool status (on any pgpool node): PGPASSWORD=$CHECK_PASSWORD psql -U $CHECK_USER -h localhost template1 -c "show pool_nodes"
  • In pgpool container check if primary node exists: /usr/local/bin/pgpool/has_write_node.sh

Any command might be wrapped with docker-compose or kubectl - docker-compose exec {NODE} bash -c '{COMMAND}' or kubectl exec {POD_NAME} -- bash -c '{COMMAND}'

Scenarios

Check the document to understand different cases of failover, split-brain resistance and recovery

Publications

  • Article on ***
  • Статья на habr-e

How to contribute

Check the doc to understand how to contribute

FAQ

  • Example of real/live usage:
    • Lazada/Alibaba Group
  • Why not sorintlab/stolon:
    • Complex logic with a lot of go-code
    • Non-standard tools for Postgres ecosystem
  • How to promote master, after failover on postgresql with docker
  • Killing of node in the middle (e.g. pgslave1) will cause dieing of whole branch
    • That make seance as second or deeper level of replication should not be able to connect to root master (it makes extra load on server) or change upstream at all

Documentation and manuals

  • Streaming replication in postgres: [***]
  • Repmgr: [***]
  • Pgpool2: [***]
  • Barman: [***]
  • Kubernetes: [***]
查看更多 postgres 相关镜像 →
postgres logo
postgres
Docker 官方镜像
PostgreSQL作为一款功能强大的对象关系型数据库系统,凭借其先进的架构设计与完善的技术机制,不仅能高效融合关系型数据的结构化管理与对象型数据的灵活扩展,更通过严格的ACID事务支持、多版本并发控制及全面的数据校验机制,为各类应用场景提供卓越的系统可靠性与极致的数据完整性保障,是全球广泛应用的开源数据库优选方案。
1.5万 次收藏10亿+ 次下载
14 天前更新
cimg/postgres logo
cimg/postgres
cimg
CircleCI便捷镜像,集成PostgreSQL数据库,用于CI/CD流程中快速部署和运行PostgreSQL相关的测试及开发任务,简化配置。
9 次收藏5亿+ 次下载
1 个月前更新
circleci/postgres logo
circleci/postgres
circleci
The PostgreSQL object-relational database system provides reliability and data integrity.
35 次收藏5亿+ 次下载
4 年前更新
kasmweb/postgres logo
kasmweb/postgres
kasmweb
Kasm Technologies维护的Postgres镜像,包含pg_audit及其他修改。
6 次收藏10万+ 次下载
6 天前更新
ubuntu/postgres logo
ubuntu/postgres
Ubuntu 官方镜像
PostgreSQL是一款开源的对象关系型数据库,它功能强大、稳定性高,广泛应用于各类企业级应用和数据管理场景,支持复杂查询、事务处理及高级数据类型,其长期版本由Canonical负责维护,为用户提供持续的技术支持与更新服务,确保数据库系统在长期使用中的可靠性与安全性,是全球众多开发者和企业信赖的主流数据库解决方案之一。
42 次收藏50万+ 次下载
6 天前更新
chainguard/postgres logo
chainguard/postgres
chainguard
使用Chainguard的低至零CVE容器镜像构建、发布和运行安全软件。
1 次收藏5万+ 次下载
6 天前更新

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

Docker 配置

登录仓库拉取

通过 Docker 登录认证访问私有仓库

专属域名拉取

无需登录使用专属域名

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

HPC 科学计算容器配置

其他仓库配置

ghcr、Quay、nvcr 等镜像仓库

系统配置

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

MacOS OrbStack

MacOS OrbStack 容器配置

Docker Compose

Docker Compose 项目配置

NAS 设备

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

极空间

极空间 NAS 系统配置服务

网络设备

爱快路由

爱快 iKuai 路由系统配置

宝塔面板

在宝塔面板一键配置镜像

需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单

镜像拉取常见问题

使用与功能问题

docker search 报错:专属域名下仅支持 Docker Hub 查询

docker search 报错问题

网页搜不到镜像:Docker Hub 有但轩辕镜像搜索无结果

镜像搜索不到

离线传输镜像:无法直连时用 docker save/load 迁移

离线传输镜像

Docker 插件安装错误:application/vnd.docker.plugin.v1+json

Docker 插件安装错误

WSL 下 Docker 拉取慢:网络与挂载目录影响及优化

WSL 拉取镜像慢

轩辕镜像是否安全?镜像完整性校验(digest)说明

镜像安全性

如何用轩辕镜像拉取镜像?登录方式与专属域名配置

如何拉取镜像

错误码与失败问题

manifest unknown 错误:镜像不存在或标签错误

manifest unknown 错误

TLS/SSL 证书验证失败:Docker pull 时 HTTPS 证书错误

TLS 证书验证失败

DNS 解析超时:无法解析镜像仓库地址或连接超时

DNS 解析超时

410 Gone 错误:Docker 版本过低导致协议不兼容

410 错误:版本过低

402 Payment Required 错误:流量耗尽错误提示

402 错误:流量耗尽

401 UNAUTHORIZED 错误:身份认证失败或登录信息错误

身份认证失败错误

429 Too Many Requests 错误:请求频率超出专业版限制

429 限流错误

Docker login 凭证保存错误:Cannot autolaunch D-Bus(不影响登录)

凭证保存错误

账号 / 计费 / 权限

免费版与专业版区别:功能、限额与使用场景对比

免费版与专业版区别

支持的镜像仓库:Docker Hub、GCR、GHCR、K8s 等列表

轩辕镜像支持的镜像仓库

拉取失败是否扣流量?计费规则说明

拉取失败流量计费

KYSEC 权限不够:麒麟 V10/统信 UOS 下脚本执行被拦截

KYSEC 权限错误

如何申请开具发票?(增值税普票/专票)

开具发票

如何修改网站与仓库登录密码?

修改网站和仓库密码

配置与原理类

registry-mirrors 未生效:仍访问官方仓库或报错的原因

registry-mirrors 未生效

如何去掉镜像名称中的轩辕域名前缀?(docker tag)

去掉域名前缀

如何拉取指定架构镜像?(ARM64/AMD64 等多架构)

拉取指定架构镜像

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
postdock/postgres
博客公告Docker 镜像公告与技术博客
热门镜像查看热门 Docker 镜像推荐
一键安装一键安装 Docker 并配置镜像源
镜像拉取问题咨询请 提交工单,官方技术交流群:1072982923。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
镜像拉取问题咨询请提交工单,官方技术交流群:。轩辕镜像所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
商务合作:点击复制邮箱
©2024-2026 源码跳动
商务合作:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.