8000 GitHub - goodplayer/image_postgres: Postgres Docker Image with advanced features
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

goodplayer/image_postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Postgres Container

1. Features

  • Postgres container with contrib extensions
  • Supporting version specific data folder for major version upgrading
  • Supporting auto-upgrade at container startup with the recent two postgres major versions(latest and one previous)
  • Supporting customizing postgres configuration
    • Mapping configure files: *.conf => /pgconf/*.conf
  • Supporting customizing data folder
    • Mapping data folder: => /pgdata
    • Mapping data wal folder: => /pgdata_wal
  • Supporting starting container from both fresh new and existing instance
  • Supporting safe container stop
  • Larger uid and gid of data files
    • Note: please ensure the uid and gid when mounting a volumn
    • Current UID: 30000
    • Current GID: 30000
  • Supporting customize extension
  • Supporting customize initdb parameters
  • Supporting ssl configuration & custom CA
  • Support postgresql archive mode
  • Support init standby database from primary database
    • run container with parameters: new_standby 17 127.0.0.1 5432 repusr repusr replicaton_slot_name
    • Note: must keep configurations same between primary instance and standby instances, otherwise postgres may reject to start
Pending list
  • Add parameters in dockerfile and scripts to support multiple version or configuration when building images
  • Provide build image for extension build
  • Podman stop and systemd conflict: cannot safely shutdown in systemd startup

2. Getting started

Start new instance

# create container
podman create --name sample_pg \
    -p 5432:5432 \
    -v /home/server/pgdata:/pgdata \
    -v /home/server/pgdata_wal:/pgdata_wal \
    goodplayer/image_postgres:v17.2

# start container
podman start sample_pg

# view log
podman logs -f sample_pg

# stop container
podman stop -t 120 sample_pg

# remove container
podman rm sample_pg

New standby instance from primary

podman run --name pg_standby_init \
    -v /home/server/demo1/pgdata:/pgdata \
    -v /home/server/demo1/pgdata_wal:/pgdata_wal \
    goodplayer/image_postgres:v17.2 new_standby 17 10.11.0.5 5432 repusr repusr rep_slot_1

podman rm pg_standby_init

podman create --name sample_pg \
    -p 5432:5432 \
    -v /home/server/demo1/pgdata:/pgdata \
    -v /home/server/demo1/pgdata_wal:/pgdata_wal \
    -v /home/server/01-pgcustom.conf:/pgconf/01-pgcustom.conf \
    goodplayer/image_postgres:v17.2

podman start sample_pg

Default settings for container mapping:

  • Postgres port: 5432
  • Postgres data folder: /pgdata
  • Postgres data wal folder: /pgdata_wal
  • Custom postgres conf folder: /pgconf

Custom configure:

# create custom conf file
touch /home/server/01-pgcustom.conf

# add parameter as a mounted file:
# -v /home/server/01-pgcustom.conf:/pgconf/01-pgcustom.conf
  • TODO specify parameters, mount required files

3. Build image(postgresql 17.2)

  1. Download postgresql-17.2.tar.bz2 file from postgresql website
    • Please refer to the Dockerfile for the actual files to download
  2. Run builder
    • podman build --no-cache --force-rm --squash-all -t goodplayer/image_postgres:v17.2 .
  3. Push to registry
    • podman login -u docker -p docker docker-push.registry.internal:5001
    • podman push goodplayer/image_postgres:v17.2 docker-push.registry.internal:5001/goodplayer/image_postgres:v17.2

Require modification when upgrade to a new version

  1. ARGs at the beginning in Dockerfile: source files to build
  2. CMD parameter in Dockerfile: data folder link name
  3. MIN and MAX version in check version function in entrypoint.sh: version check for upgrade

Customization

1. Customize debian repository

Edit debian.sources file before building the image.

2. Customize postgresql configure files

Edit files in pgconf folder before building the image.

The files will be the default configuration in the image.

Test scenarios

  • Startup on fresh new instance
  • Restart from an existing instance
  • Restart on an old instance of supported versions
  • Restart on an old instance of unsupported versions(instance version < minimum supported versions)
  • Restart on an new instance of unsupported versions(instance version > maximum supported versions)
  • Stop the instance gracefully

A. References

About

Postgres Docker Image with advanced features

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0