Sign inSign up

goodrainapps/postgresql

By goodrainapps

•Updated over 9 years ago

PostgreSQL application for Goodrain ACP

Image
1

1.5K

goodrainapps/postgresql repository overview

⁠PostgreSQL for ACP⁠

PostgreSQL is a powerful, open source object-relational database system. It has more than 15 years of active development and a proven architecture that has earned it a strong reputation for reliability, data integrity, and correctness. It runs on all major operating systems, including Linux, UNIX (AIX, BSD, HP-UX, SGI IRIX, macOS, Solaris, Tru64), and Windows. It is fully ACID compliant, has full support for foreign keys, joins, views, triggers, and stored procedures (in multiple languages).

postgresql

9.6 , 9.6.3 , latest Dockerfile⁠

9.5 , 9.5.7 Dockerfile⁠

9.4 , 9.4.12 Dockerfile⁠

9.3 , 9.3.17 Dockerfile⁠

⁠About this image

This images base alpine system ,can be installed in Goodrain ACM⁠. Fully compatible with the Goodrain ACP⁠ platform.

⁠How to use this image

⁠Via ACM install

deploy to ACP

⁠Via docker

⁠Installation

Automated builds of the image are available on hub.docker.com⁠ and is the recommended method of installation.

docker pull goodrainapps/postgresql:9.4.12

Alternately you can build the image yourself.

https://github.com/goodrain-apps/docker-postgresql.git
cd docker-postgresql
git branch 9.4
make base
make build
make release
⁠Quick Start

Run the postgresql image

docker run -d --name posgresql goodrainapps/postgresql:9.4.12

The simplest way to login to the postgresql container as the administrative postgres user is to use the docker exec command to attach a new process to the running container and connect to the postgresql server over the unix socket,postgres user default password is pass4you

docker exec -it postgresql sudo -u postgres psql
⁠Persistence

For data persistence a volume should be mounted at /usr/local/pgsql/data.

The updated run command looks like this.

docker run -d --name posgresql
-v ${PWD}/data:/usr/local/pgsql/data
goodrainapps/postgresql:9.4.12

This will make sure that the data stored in the database is not lost when the image is stopped and started again.

⁠Creating User and Database at Launch

The image allows you to create a user and database at first launch time.

To create a new user you should specify the DB_USER and DB_PASS variables. The following command will create a new user dbuser with the password dbpass.

docker run --name postgresql -d \
  -e 'DB_USER=dbuser' \
  -e 'DB_PASS=dbpass' \
  goodrainapps/postgresql:9.4.12

NOTE

  • If the password is not specified the user will use default password pass4you
  • If the user user already exists no changes will be made

Similarly, you can also create a new database by specifying the database name in the DB_NAME variable.

docker run --name postgresql -d \
  -e 'DB_NAME=dbname' goodrainapps/postgresql:9.4.12

You may also specify a comma separated list of database names in the DB_NAME variable. The following command creates two new databases named dbname1 and dbname2 (p.s. this feature is only available in releases greater than 9.1-1).

docker run --name postgresql -d \
  -e 'DB_NAME=dbname1,dbname2' \
  goodrainapps/postgresql:9.4.12

If the DB_USER and DB_PASS variables are also specified while creating the database, then the user is granted access to the database(s).

For example,

docker run --name postgresql -d \
  -e 'DB_USER=dbuser' \
  -e 'DB_PASS=dbpass' \
  -e 'DB_NAME=dbname' \
  goodrainapps/postgresql:9.4.12

will create a user dbuser with the password dbpass. It will also create a database named dbname and the dbuser user will have full access to the dbname database.

The PSQL_TRUST_LOCALNET environment variable can be used to configure postgres to trust connections on the same network. This is handy for other containers to connect without authentication. To enable this behavior, set PSQL_TRUST_LOCALNET to true.

For example,

docker run --name postgresql -d \
  -e 'PSQL_TRUST_LOCALNET=true' \
  goodrainapps/postgresql:9.4.12

This has the effect of adding the following to the pg_hba.conf file:

host    all             all             samenet                 trust
⁠Enable Unaccent (Search plain text with accent)

Unaccent is a text search dictionary that removes accents (diacritic signs) from lexemes. It's a filtering dictionary, which means its output is always passed to the next dictionary (if any), unlike the normal behavior of dictionaries. This allows accent-insensitive processing for full text search.

By default unaccent is configure to false

docker run --name postgresql -d \
  -e 'DB_UNACCENT=true' \
  goodrainapps/postgresql:9.4.12

⁠Environment variables

NameDefaultComments
DB_NAMEadminThe DB_NAME was created the first time it was started
DB_USER / POSTGRESQL_USERadminDB_USER created at the first start
DB_PASS / POSTGRESQL_PASSpass4youThe DB_PASS created at the first start
PSQL_MODEstandalonepostgresql run mode
DB_UNACCENTfalseEnable Unaccent
PSQL_SSLMODEdisablessl connect
DEBUGnulldocker-entrypoint.sh debug switch
PAUSEnulldocker-entrypoint.sh pause for debug

⁠Custom postgresql.conf

This image supports modifying the postgresql.conf configuration item when the container is started.

The following settings are set up by default:

CFG_SSl=${CFG_SSl:-off}
CFG_TIMEZONE=${CFG_TIMEZONE:-Asia/Shanghai}
CFG_LOG_TIMEZONE=${CFG_LOG_TIMEZONE:-Asia/Shanghai}

You can specify the configuration when starting the container, such as setting the max_connections,environment variable name must begin with CFG_

docker run -d \
-e DB_PASS=abc123 \
-e DB_USER=goodrain \
-e DB_NAME=grtest \
-e DEBUG=1 \
-e CFG_MAX_CONNECTIONS=200  \
goodrainapps/postgresql:9.4.12

Tag summary

Content type

Image

Digest

Size

15.2 MB

Last updated

over 9 years ago

docker pull goodrainapps/postgresql