All Projects → utensils → Docker Postgres

utensils / Docker Postgres

Licence: mit
A docker container running PostgreSQL

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to Docker Postgres

Doctrine Postgis
Spatial and Geographic Data with PostGIS and Doctrine.
Stars: ✭ 161 (+631.82%)
Mutual labels:  postgis, database, postgresql, postgres
Php Crud Api
Single file PHP script that adds a REST API to a SQL database
Stars: ✭ 2,904 (+13100%)
Mutual labels:  postgis, database, postgresql
Rpostgres
A DBI-compliant interface to PostgreSQL
Stars: ✭ 245 (+1013.64%)
Mutual labels:  database, postgresql, postgres
Dbq
Zero boilerplate database operations for Go
Stars: ✭ 273 (+1140.91%)
Mutual labels:  database, postgresql, postgres
Metabase
The simplest, fastest way to get business intelligence and analytics to everyone in your company 😋
Stars: ✭ 26,803 (+121731.82%)
Mutual labels:  database, postgresql, postgres
Prest
PostgreSQL ➕ REST, low-code, simplify and accelerate development, ⚡ instant, realtime, high-performance on any Postgres application, existing or new
Stars: ✭ 3,023 (+13640.91%)
Mutual labels:  database, postgresql, postgres
Pg chameleon
MySQL to PostgreSQL replica system
Stars: ✭ 274 (+1145.45%)
Mutual labels:  database, postgresql, postgres
Condenser
Condenser is a database subsetting tool
Stars: ✭ 189 (+759.09%)
Mutual labels:  database, postgresql, postgres
Jet
Type safe SQL builder with code generation and automatic query result data mapping
Stars: ✭ 373 (+1595.45%)
Mutual labels:  database, postgresql, postgres
Sqlboiler
Generate a Go ORM tailored to your database schema.
Stars: ✭ 4,497 (+20340.91%)
Mutual labels:  database, postgresql, postgres
Citus
Distributed PostgreSQL as an extension
Stars: ✭ 5,580 (+25263.64%)
Mutual labels:  database, postgresql, postgres
Massive Js
A data mapper for Node.js and PostgreSQL.
Stars: ✭ 2,521 (+11359.09%)
Mutual labels:  database, postgresql, postgres
Postgres
🐘 Run PostgreSQL in Kubernetes
Stars: ✭ 205 (+831.82%)
Mutual labels:  database, postgresql, postgres
Npgsql
Npgsql is the .NET data provider for PostgreSQL.
Stars: ✭ 2,415 (+10877.27%)
Mutual labels:  database, postgresql, postgres
Blog
Everything about database,business.(Most for PostgreSQL).
Stars: ✭ 6,330 (+28672.73%)
Mutual labels:  database, postgresql, postgres
Postgui
A React web application to query and share any PostgreSQL database.
Stars: ✭ 260 (+1081.82%)
Mutual labels:  database, postgresql, postgres
Pg hashids
Short unique id generator for PostgreSQL, using hashids
Stars: ✭ 164 (+645.45%)
Mutual labels:  database, postgresql, postgres
Postgres
Postgres.js - The Fastest full featured PostgreSQL client for Node.js
Stars: ✭ 2,193 (+9868.18%)
Mutual labels:  database, postgresql, postgres
Ansible Role Postgresql
Ansible Role - PostgreSQL
Stars: ✭ 310 (+1309.09%)
Mutual labels:  database, postgresql, postgres
Pgmetrics
Collect and display information and stats from a running PostgreSQL server
Stars: ✭ 612 (+2681.82%)
Mutual labels:  database, postgresql, postgres

Docker Container for PostgreSQL (latest version - 10.3)

Build Status Docker Automated build Docker Pulls Docker Stars

About

This is a highly configurable container for PostgreSQL 9.6. It allows for basic initial user/pass and schema configuration via ENV variables.

Extensions

This container is preloaded with the following extensions.

Usage

To run with default settings

docker run -P --name postgres jamesbrink/postgres

To run with customized settings

docker run -P --name postgres -e USER=foo -e PASSWORD=bar -e DATABASE=foo -e ENCODING=UTF8 jamesbrink/postgres

This will create a new container with the username and schema of foo encoded in UTF-8 and a password of bar

To add PostGIS support to the database pass the environment variable POSTGIS=true.

docker run -P --name postgresql -e USER=foo -e PASSWORD=bar -e DATABASE=foo -e ENCODING=UTF8 -e POSTGIS=true jamesbrink/postgresql

Here is an example of the run. Take note of the user/pass and schema when you start the container as it will not be shown again. Of course you can change these settings and add additional users and schemas at any point.

[email protected]:~$ docker run -P --name postgres jamesbrink/postgresql
Waiting for PostgreSQL to start
2014-04-21 20:36:42 UTC LOG:  database system was shut down at 2014-04-21 04:34:43 UTC
2014-04-21 20:36:42 UTC LOG:  autovacuum launcher started
2014-04-21 20:36:42 UTC LOG:  database system is ready to accept connections
Below are your configured options.
================
USER: postgres
PASSWORD: postgres
DATABASE: public
POSTGIS: false
================
ALTER ROLE

Container Linking

Here are some examples of linking containers to postgresql

First we create a container, here I am using a random password generated from openssl

[email protected]:~$ docker run -P --name postgres -e PASSWORD=`openssl rand -hex 10` -e USER=james -e DATABASE=test jamesbrink/postgresql
Waiting for PostgreSQL to start
Below are your configured options.
================
USER: james
PASSWORD: 5387fc737962925e2c70
DATABASE: test
POSTGIS: false
ENCODING: SQL_ASCII
================
2014-04-21 21:07:24 UTC LOG:  database system was shut down at 2014-04-21 04:34:43 UTC
2014-04-21 21:07:24 UTC LOG:  autovacuum launcher started
2014-04-21 21:07:24 UTC LOG:  database system is ready to accept connections
CREATE USER

With the postgres container up and running, lets create a new container and link it with an alias of db.

[email protected]:~$ docker run -i -t --link postgres:db ubuntu /bin/bash

Now from inside the container ensure you have a postgresql client installed.

install postgresql-client

You can now connect to the database in a variety of ways. lets first inspect the environment. The variables of interest here are all prefixed with DB_

env
HOSTNAME=47b16d7d1e13
DB_NAME=/cocky_babbage/db
TERM=xterm
DB_PORT_5432_TCP_ADDR=172.17.0.2
DB_ENV_DATABASE=test
DB_PORT=tcp://172.17.0.2:5432
DB_PORT_5432_TCP=tcp://172.17.0.2:5432
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
DB_ENV_PASSWORD=5387fc737962925e2c70
DB_PORT_5432_TCP_PORT=5432
SHLVL=1
HOME=/
DB_ENV_USER=james
DB_PORT_5432_TCP_PROTO=tcp
_=/usr/bin/env

Connect manually.

-h 172.17.0.2 -U james test
Password for user james:
psql (9.1.13, server 9.3.4)
WARNING: psql version 9.1, server version 9.3.
     Some psql features might not work.
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
test=#

Connect using ENV variables.

PGPASSWORD=$DB_ENV_PASSWORD psql -h $DB_PORT_5432_TCP_ADDR -U $DB_ENV_USER $DB_ENV_DATABASE
psql (9.1.13, server 9.3.4)
WARNING: psql version 9.1, server version 9.3.
     Some psql features might not work.
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
test=#

Create an application friendly URI.

export DB_URI=postgres://$DB_ENV_USER:$DB_ENV_PASSWORD@$DB_PORT_5432_TCP_ADDR:$DB_PORT_5432_TCP_PORT/$DB_ENV_DATABASE
echo $DB_URI
postgres://james:[email protected]:5432/test

Data Volumes

The following directories are setup as volumes and can be accessed from other containers.

  • /etc/postgresql
  • /var/lib/postgresql
  • /var/log/postgresql

Example of connecting the volumes to a container.

[email protected]:~$ docker run --volumes-from postgres -i -t ubuntu bash
[email protected]:/# mount |grep postgresql
/dev/disk/by-uuid/cb08824e-c579-4fbc-8fea-668fafa212cc on /etc/postgresql type ext4 (rw,relatime,errors=remount-ro,data=ordered)
/dev/disk/by-uuid/cb08824e-c579-4fbc-8fea-668fafa212cc on /var/lib/postgresql type ext4 (rw,relatime,errors=remount-ro,data=ordered)
/dev/disk/by-uuid/cb08824e-c579-4fbc-8fea-668fafa212cc on /var/log/postgresql type ext4 (rw,relatime,errors=remount-ro,data=ordered)

Environment Variables

This is a list of the available environment variables which can be set at runtime using -e KEY=value. For example, to change the default password you can issue docker run -P --name postgresql -e PASSWORD=mysecretpassword jamesbrink/postgresql

  • USER: A superuser role. default: postgres
  • PASSWORD: The password for the user. default: postgres
  • DATABASE: Name of the database to create. default: postgres
  • SCHEMA: Name of the schema to create. default: public
  • ENCODING: Encoding of the schema we are about to create. default: SQL_ASCII
  • LOCALE: locale setting. default: en_US.UTF-8
  • POSTGIS: Enable PostGIS extensions on the schema.

Backups

Be sure to run regular backups of any production databases. This can be handled in many different ways and I will not go into details here about how you should handle your backups. For additional information on backing up databases refer to the PostgreSQL 9.6 Documentation on Backups

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].