Sign inSign up

heimergroup/postgres

By heimergroup

•Updated about 9 years ago

PostgreSQL server images based on openSUSE official repository.

Image
0

739

heimergroup/postgres repository overview

⁠Introduction

This PostgreSQL⁠ server image is based on opensuse⁠:latest and using the OBS repository server:database:postgresql for the DB package itself.

The version of the DB is specified by the tag of the image.

⁠Environment variables used by the image to create the container
  • POSTGRES_HOME : Defaults to '/var/lib/pgsql'. This is also the VOLUME exposed by the image. If you change this it may cause problem.
  • POSTGRES_USER : Defaults to 'postgres'. If you want the final DB to be owned by another user set it.
  • POSTGRES_PASSWORD : Defaults to trust with no password unless one is supplied. Set this if the owner connecting should use a password and defaults to 'md5' in the DB auth files.
  • DBENCODING : Defaults to 'UTF8'
  • DBLOCALE : Defaults to 'en_US.utf8'
⁠Using the image to setup a base DB server

For persistent data storage be sure to create a volume to contain it before or during container creation. Beware of data lose if you do not store your data in a volume.

To start the DB server in the simplest of terms with no persistent storage across container upgrades:

docker run -d --name postgres-dbs heimergroup/postgres

More complete example with persistent storage of data, other than default username (also name of the database) and with a password, and on a different network than the default bridge (NOTE: Create the network first):

docker run -d -e POSTGRES_USER=auser \
-e POSTGRES_PASSWORD=apasswd \
--name auser-dbs --network somenetwork \
--volume auser-dbs-data:/var/lib/pgsql heimergroup/postgres

You may or may not have to expose the port depending on how you will connect to the DB. Now with it running you can load data with whatever process you wish or below you can create an image with this as the base and preload tables, data, etc.

⁠Using the image as the base for your image

If you use this image as the base for your image the entry point will allow you to run extra scripts as needed, load tables so they already exist in your image, etc.

Create the directory 'docker-entrypoint.d' in your build directory. The entry point will look for files matching the patterns *.sh and *.sql in the directory and execute them one by one when the container is created. NOTE: This only applies if the DB does not already exist, restarting the container will not cause these items to run again. To have them load in order place a sequence number at the beginning of the filename, such as 001, 002, etc. These scripts and SQL can do various things such as creating your DB schema before loading in your initial data. *.sh files are executed with /bin/bash and *.sql files are executed via psql as the POSTGRES_USER.

⁠Example Dockerfile
FROM heimergroup/postgres:latest
COPY ./docker-entrypoint.d /docker-entrypoint.d

This is an example of how the Zabbix database tables are created and automatically loaded for the image zabbix-dbs⁠.

Tag summary

Content type

Image

Digest

Size

117.3 MB

Last updated

about 9 years ago

docker pull heimergroup/postgres