|
| 1 | +# tklx/postgresql - SQL database |
| 2 | + |
| 3 | +[](https://circleci.com/gh/tklx/postgres) |
| 4 | + |
| 5 | +[PostgreSQL][postgres], often simply Postgres, is an object-relational database management system (ORDBMS) with an emphasis on extensibility and standards-compliance. As a database server, its primary function is to store data securely, and to allow for retrieval at the request of other software applications. It can handle workloads ranging from small single-machine applications to large Internet-facing applications with many concurrent users. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- Based on the super slim [tklx/base][base] (Debian GNU/Linux). |
| 10 | +- PostgreSQL installed directly from Debian. |
| 11 | +- Uses [tini][tini] for zombie reaping and signal forwarding. |
| 12 | +- Uses [gosu][gosu] for dropping privileges to postgres user. |
| 13 | +- Includes ``VOLUME /var/lib/postgresql/data`` for persistence. |
| 14 | +- Includes ``EXPOSE 5432``, so standard container linking will make it |
| 15 | + automatically available to the linked containers. |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +### Start a postgres instance and connect to it from an application |
| 20 | + |
| 21 | +```console |
| 22 | +$ docker run --name some-postgres -e POSTGRES_PASSWORD='secretpass' -d tklx/postgres |
| 23 | +$ docker run --name some-app --link some-postgres:postgres -d app-that-uses-postgres |
| 24 | +``` |
| 25 | + |
| 26 | +### Initialization |
| 27 | + |
| 28 | +The image can be initialized by passing the following options as [environment variables][1] to ```docker run```: |
| 29 | + |
| 30 | + PGDATA - Postgres data location (/var/lib/postgresql/data by default) |
| 31 | + POSTGRES_DB - name of database to initialize |
| 32 | + POSTGRES_USER - name of database user to assign as owner of POSTGRES_DB |
| 33 | + POSTGRES_PASSWORD - password for database user or ```postgres``` if user not specified |
| 34 | + |
| 35 | +```POSTGRES_PASSWORD``` is required for remote access (e. g. from linked containers). If it is not supplied and the datastore was not already initialized, only local access will be allowed. |
| 36 | + |
| 37 | +### Tips |
| 38 | + |
| 39 | +```console |
| 40 | +# postgresql client options |
| 41 | +$ docker run --rm tklx/postgresql psql --help |
| 42 | + |
| 43 | +# postgres options |
| 44 | +$ docker run --rm tklx/postgresql --help |
| 45 | + |
| 46 | +# launch a regular PostgreSQL instance |
| 47 | +$ docker run --name some-postgres -e POSTGRES_USER=someuser POSTGRES_DB=somedb -e POSTGRES_PASSWORD=mysecretpassword -d tklx/postgres |
| 48 | + |
| 49 | +# link an application to it |
| 50 | +$ docker run --name some-app --link some-postgres:tklx/postgres -d app-that-uses-postgres |
| 51 | + |
| 52 | +# access through psql |
| 53 | +$ docker run -it --rm --link some-postgres:tklx/postgres tklx/postgres psql -h postgres -U postgres |
| 54 | +psql (9.4.8) |
| 55 | +Type "help" for help. |
| 56 | + |
| 57 | +postgres=# SELECT 1; |
| 58 | + ?column? |
| 59 | +---------- |
| 60 | + 1 |
| 61 | +(1 row) |
| 62 | + |
| 63 | +# local access through psql |
| 64 | +$ docker exec -it some-postgres psql -h localhost -U postgres |
| 65 | + |
| 66 | +``` |
| 67 | + |
| 68 | +## Automated builds |
| 69 | + |
| 70 | +The [Docker image](https://hub.docker.com/r/tklx/postgres/) is built, tested and pushed by [CircleCI](https://circleci.com/gh/tklx/postgres) from source hosted on [GitHub](https://github.com/tklx/postgres). |
| 71 | + |
| 72 | +* Tag: ``x.y.z`` refers to a [release](https://github.com/tklx/mongodb/releases) (recommended). |
| 73 | +* Tag: ``latest`` refers to the master branch. |
| 74 | + |
| 75 | +## Status |
| 76 | + |
| 77 | +Currently on major version zero (0.y.z). Per [Semantic Versioning][semver], |
| 78 | +major version zero is for initial development, and should not be considered |
| 79 | +stable. Anything may change at any time. |
| 80 | + |
| 81 | +## Issue Tracker |
| 82 | + |
| 83 | +TKLX uses a central [issue tracker][tracker] on GitHub for reporting and |
| 84 | +tracking of bugs, issues and feature requests. |
| 85 | + |
| 86 | +[postgres]: https://www.postgresql.org/ |
| 87 | +[base]: https://github.com/tklx/base |
| 88 | +[tini]: https://github.com/krallin/tini |
| 89 | +[gosu]: https://github.com/tianon/gosu |
| 90 | +[semver]: http://semver.org/ |
| 91 | +[tracker]: https://github.com/tklx/tracker/issues |
0 commit comments