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

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

官方QQ群: 1072982923

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

热门搜索:openclaw🔥nginx🔥redis🔥mysqlopenjdkcursorweb2apimemgraphzabbixetcdubuntucorednsjdk
postgresql
gjrtimmer/postgresql
gjrtimmer
Dockerized PostgreSQL (Alpine)
1 次收藏下载次数: 0状态:社区镜像维护者:gjrtimmer仓库类型:镜像最近更新:1 年前
轩辕镜像,快一点,稳很多。点击查看
镜像简介版本下载
轩辕镜像,快一点,稳很多。点击查看

PostgreSQL

Configurable PostgreSQL server with backup,snapshot,standby,hot standby,ssl/tls and much more easy configuration through environment variables. Including examples to get you started quickly. The source code for this repository can be found here on GitHub gjrtimmer/docker-postgresql.

Table of Contents

  • Quick Start
  • PostgreSQL Versions
  • Features
  • Environment variables
  • Timezone Configuration
  • File Permissions
  • Persistent Storage
  • Custom Container Initialization
  • Custom Services
  • Creating Databases
  • Database Initialization
  • Enabling Extensions
  • Creating a Backup
  • Creating a Snapshot
  • Creating a Standby Server
  • Automatic failover / cluster management

Quick Start

bash
docker run --detach -p 5432:5432 gjrtimmer/postgresql:latest

PostgreSQL Versions

Currently this repository supports the following PostgreSQL versions:

  • 9 (gjrtimmer/postgresql:9)
  • 10 (gjrtimmer/postgresql:10)
  • 11 (gjrtimmer/postgresql:11)
  • 12 (gjrtimmer/postgresql:12)
  • 13 (gjrtimmer/postgresql:13)
  • 14 (gjrtimmer/postgresql:14)
  • 15 (gjrtimmer/postgresql:15) (latest)

The container is build upon alpine linux from linuxserver.

Features

The following are the key features, read the full documentation to understand everything which is supported.

FeatureDescription
Host file permissionsSet data file permissions
BackupEasy backup your live running master node with a script or docker-compose file
SnapshotCreate a snapshot of a server and then run it, very handy for developers whom need a clone of a running server to work local
StandbyAdd standby nodes to your master
Hot StandbyAdd hot standby nodes to your master to allow read-only queries to your standby nodes
TLS/SSLEasy configure SSL/TLS through environment variable
Automatic upgrade/migrationAutomatic database upgrade with migration to new version
Create databases on startupCreate multiple new databases on container startup
Database template definitionConfigure the database template to be used for creating new databases
Database initializationInitialize databases on startup with SQL, including support for different SQL files per database
Extension supportLoad extensions into databases through environment variables
PL/PerlPL/Perl Language support
PL/PythonPL/Python Language support
PL/TCLPL/TCL Language support
pg_cronEnable PG_CRON database scheduler for database cron jobs
Performance configurationPerformance configuration through environment variables
Automatic cluster managementAutomatic cluster management with repmgr

Environment variables

For a full list of features / environment variables, please look here Environment Variables

Timezone Configuration

Set the timezone for the container, defaults to UTC. To set the timezone set the desired timezone with the variable TZ.

Please use the timezone database format for configuring the timezone.

Example: TZ=Europe/Amsterdam

File Permissions

This container si based upon alpine linux from linuxserver. This means it comes with full support for the PUID and PGID variables.

Using the PUID and PGID allows our containers to map the container's internal user to a user on the host machine. All of our containers use this method of user mapping and should be applied accordingly.

More information can be found here: linuxserver: understanding PUID/PGID

ENVVARDefaultDescription
PUID1000Map user ownership to provided value
PGID1000Map group ownership to provided value

Persistent Storage

By default everything is stored in the mount point /config. In orer to configure persistent storage the /config mount point has to be mapped either to a volume or host directory.

Some default storage locations can be configured with environment variables. For a complete list see Environment Variables.

ENVVARDefaultDescription
HOME/configDefault volume
PG_HOME/config/dataPostgreSQL home
PG_DATA_DIR/config/data/{VERSION}/mainPostgreSQL data directory
PG_CERTS_DIR/config/certsCertificate directory
PG_LOG_DIR/config/logsLog directory
PG_INIT_DB_DIR/config/initdb.dDatabase initialization scripts

Custom Container Initialization

Because this image is based upon the alpine linux base image from linuxserver.io its also possible to provide your own custom initialization scripts for the container.

This can be done by providing your own scripts in the /config/custom-cont-init.d directory.

Custom Services

Because this image is based upon the alpine linux base image from linuxserver.io its also possible to provide your own custom services within the container.

Custom services can be placed in the /config/custom-services.d directory.

Creating Databases

A new PostgreSQL database can be created by specifying the DB_NAME variable while starting the container.

Example: DB_NAME=dbname

By default databases are created by copying the standard system database named template1. You can specify a different template for your database using the DB_TEMPLATE parameter. Refer to Template Databases for further information.

Additionally, more than one database can be created by specifying a comma separated list of database names in DB_NAME. For example, setting the DB_NAME variable to the following creates two new databases named dbname1 and dbname2.

Example: DB_NAME=dbname1,dbname2

Database Initialization

Because this image is able to initalize multiple database; in several cases you want to be able to initialize a database with tables / indexes etc...

For this scenario this image provides a volume location for database initialization PG_INIT_DB_DIR (/config/initdb.d). In this volume location sql files are expected with the following format <ID>-<DB_NAME>-<additional name>.sql.

The ID is an id to order the files for loading in a specific order.

This can be used not only for specific initialization for separate databases but also for global configuration. In the scenario that you start a container which creates a new user with password and 2 databases and you also want to create additional users you can use this database initialization method to create the addtional users.

Example:

bash
PG_USER=postgres
PG_PASS=********
DB_USER=maintenance
DB_PASS=********
DB_NAME=orders,customers

In the example above, 2 databases are created orders and customers and the user maintenace is given access to these databases.

Using this example you can place your sql files like this.

bash
5-postgres-create-users.sql
10-orders-init.sql
10-orders-create-users.sql
10-customers-init.sql
10-customers-create-users.sql

You can even provide sql init files for the main postgres database by simply providing its database name in the name of the init script.

Enabling Extensions

Extensions can be enabled through the DB_EXTENSION environment variables. Multiple extensions can be provided by separating them with a , comma. Currently the extensions are enabled for every database created with the DB_NAME variable.

This container is shipped with the postgres contrib module which includes the following extensions.

More information about each extension can be found here.

A full list of the extensions can be found here Extension Overview

Creating a Backup

The requirements for creating a backup of a PostgreSQL server are that the server allows replication connections and that there are enough wal senders available to send the data to the backup. This means that you can even use this image as a backup image for a PostgreSQL server which does not use this image.

Backups are generated with the use of pg_basebackup

Requirements:

  • master node have wal level replica or logical.
  • master must have wal senders available
  • master must have a replication user

The backup container must be provided with the REPLICATION_* variables in order to connect to the master and create a backup.

To configure a backup container the following variables can be used.

  • REPLICATION_MODE must be set to backup
  • REPLICATION_* (Mandatory)
  • PG_BACKUP_* (Optional)

See examples/backup on how to use it.

Creating a Snapshot

Creating a snapshot is a very handy feature of this container. It will connect to a master clone the database and then run on its own. The difference between a standby and a snapshot is that a standby is read-only and updated whenever the master data is updated (streaming replication), while a snapshot is read-write and is not updated after the initial snapshot of the data from the master.

This is useful for developers to quickly snapshot the current state of a live database and use it for development/debugging purposes without altering the database on the live instance.

This is NOT a standby server, so after generating the snapshot the master will NOT stream any updates.

Snapshots are generated with the use of pg_basebackup

The snapshot container must be provided with the REPLICATION_* variables in order to connect to the master and create a snapshot.

To configure a snapshot container the following variables can be used.

  • REPLICATION_MODE must be set to snapshot
  • REPLICATION_* (Mandatory)
  • PG_SNAPSHOT_* (Optional)

See examples/snapshot on how to use it.

Creating a Standby Server

Creating a standby server means that you will have a master which will perform READ/WRITE actions, and all the data is replicated to the standby server(s). This image also supports the creation of hot standby servers.

The difference between standby servers and hot standby servers is that normal standby servers do not allow any read operation from the database, while a hot standby server can be used for read only queries. In both cases WRITE queries still only come through the master.

The standby container must be provided with the REPLICATION_* variables in order to connect to the master and receive its updates.

To configure a standby container the following variables can be used.

  • REPLICATION_MODE must be set to standby
  • REPLICATION_* (Mandatory)
  • PG_STANDBY_* (Optional)

If you want a hot standby server PG_STANDBY_HOT variable can be used.

See examples/master-standby on how to use it.

Automatic failover / cluster management

This image provides repmgr as cluster manager for automatic cluster orchestration and cluster failover/management.

IMPORTANT

Please note that while repmgr can be used in production, the implementation within the image has not been fully tested. Several dependecies for using repmgr like SSH access etc is still being implemented.

Use at your own risk

repmgr can be enabled with the variable REPMGR=enabled.

For more configuration options for repmgr see the REPMGR Configuration.

查看更多 postgresql 相关镜像 →
bitnami/postgresql logo
bitnami/postgresql
bitnami
Bitnami PostgreSQL安全镜像是一款专为PostgreSQL数据库设计的预配置、安全强化型容器镜像,集成自动更新的安全补丁、最小化攻击面架构、合规性验证工具及行业最佳安全实践,旨在简化数据库部署流程,同时保障数据存储与访问的安全性、稳定性及可靠性,适用于企业级应用场景下高效、安全的数据库环境搭建。
374 次收藏10亿+ 次下载
7 天前更新
bitnamicharts/postgresql logo
bitnamicharts/postgresql
bitnamicharts
Bitnami的PostgreSQL Helm chart,用于在Kubernetes环境中便捷部署和管理PostgreSQL数据库,支持灵活配置与可靠运行。
5 次收藏1000万+ 次下载
7 天前更新
manageiq/postgresql logo
manageiq/postgresql
manageiq
基于CentOS构建的PostgreSQL容器,专为ManageIQ平台设计,提供可靠的后端数据库服务支持。
100万+ 次下载
6 天前更新
vmware/postgresql logo
vmware/postgresql
vmware
暂无描述
2 次收藏5万+ 次下载
8 年前更新
corpusops/postgresql logo
corpusops/postgresql
corpusops
postgresql image
1万+ 次下载
6 年前更新
islandora/postgresql logo
islandora/postgresql
islandora
开源关系型数据库。
5万+ 次下载
10 天前更新

轩辕镜像配置手册

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

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访问体验非常流畅,大镜像也能快速完成下载。"

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