{"id":19635879,"url":"https://github.com/tozd/docker-postgresql","last_synced_at":"2025-04-28T08:31:34.933Z","repository":{"id":32760132,"uuid":"36351457","full_name":"tozd/docker-postgresql","owner":"tozd","description":"PostgreSQL Docker image. Read-only mirror of https://gitlab.com/tozd/docker/postgresql","archived":false,"fork":false,"pushed_at":"2024-01-03T09:29:22.000Z","size":58,"stargazers_count":1,"open_issues_count":5,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-17T20:13:42.114Z","etag":null,"topics":["docker","docker-image","postgis","postgresql"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tozd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":["plast8","mitar"]}},"created_at":"2015-05-27T07:43:04.000Z","updated_at":"2023-07-18T09:07:13.000Z","dependencies_parsed_at":"2023-11-21T17:52:00.408Z","dependency_job_id":null,"html_url":"https://github.com/tozd/docker-postgresql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tozd%2Fdocker-postgresql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tozd%2Fdocker-postgresql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tozd%2Fdocker-postgresql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tozd%2Fdocker-postgresql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tozd","download_url":"https://codeload.github.com/tozd/docker-postgresql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224102296,"owners_count":17256137,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","docker-image","postgis","postgresql"],"created_at":"2024-11-11T12:27:23.531Z","updated_at":"2024-11-11T12:27:24.621Z","avatar_url":"https://github.com/tozd.png","language":"Dockerfile","funding_links":["https://github.com/sponsors/plast8","https://github.com/sponsors/mitar"],"categories":[],"sub_categories":[],"readme":"# tozd/postgresql\n\n\u003chttps://gitlab.com/tozd/docker/postgresql\u003e\n\nAvailable as:\n\n- [`tozd/postgresql`](https://hub.docker.com/r/tozd/postgresql)\n- [`registry.gitlab.com/tozd/docker/postgresql`](https://gitlab.com/tozd/docker/postgresql/container_registry)\n\n## Image inheritance\n\n[`tozd/base`](https://gitlab.com/tozd/docker/base) ← [`tozd/dinit`](https://gitlab.com/tozd/docker/dinit) ← `tozd/postgresql`\n\n## Tags\n\n- `9.3`: PostgreSQL 9.3\n- `9.4`: PostgreSQL 9.4\n- `9.5`: PostgreSQL 9.5\n- `9.6`: PostgreSQL 9.6\n- `10`: PostgreSQL 10\n- `11`: PostgreSQL 11\n- `12`: PostgreSQL 12\n- `13`: PostgreSQL 13\n- `14`: PostgreSQL 14\n- `15`: PostgreSQL 15\n- `16`: PostgreSQL 16\n\n## Volumes\n\n- `/var/log/postgresql`: Log files when `LOG_TO_STDOUT` is not set to `1`.\n- `/var/lib/postgresql`: Persist this volume to not lose state.\n\n## Variables\n\nTo optionally initialize at the first startup:\n\n- `PGSQL_ROLE_1_USERNAME`: Username of a user to create.\n- `PGSQL_ROLE_1_PASSWORD`: Password for the created user.\n- `PGSQL_ROLE_1_FLAGS`: Any flags at user creation. Default is `LOGIN`.\n- `PGSQL_DB_1_NAME`: Name of a database to be created.\n- `PGSQL_DB_1_OWNER`: Username of the owner of the database. Must be set for database creation to work.\n- `PGSQL_DB_1_ENCODING`: Encoding for the database. Default is `UNICODE`.\n- `PGSQL_DB_1_LC_COLLATE`: Collation order for the database. Default is empty.\n- `PGSQL_DB_1_LC_CTYPE`: Character classification for the database. Default is empty.\n- `PGSQL_DB_1_TEMPLATE`: Name of the template from which to create the new database. Default is `DEFAULT`.\n- `PGSQL_DB_1_POSTGIS`: If set, PostGIS will be installed in the database.\n\nOther:\n\n- `LOG_TO_STDOUT`: If set to `1` output logs to stdout (retrievable using `docker logs`) instead of log volumes.\n\n## Ports\n\n- `5432/tcp`: Port on which PostgreSQL listens.\n\n## Description\n\nImage providing [PostgreSQL](http://www.postgresql.org/) SQL server.\n\nDifferent Docker tags provide different PostgreSQL versions.\n\nYou should make sure you mount data volume (`/var/lib/postgresql`) so that you do not\nlose database data when you are recreating a container. If a volume is empty, image\nwill initialize it at the first startup.\n\nIf you are extending this image, you can add a script `/etc/service/postgresql/run.initialization`\nwhich will be run at a container startup, after the container is initialized, but before the\nPostgreSQL daemon is run.\n\nWhen `LOG_TO_STDOUT` is set to `1`, Docker image logs output to stdout and stderr. All stdout output is JSON.\n\nThere are two ways to use this image. As a database which is shared between multiple\nother services and that you create databases and users accordingly. Or as a database\njust for one user/app.\n\n### Multiple users\n\nAfter first run, you can connect to the PostgreSQL as an administrator from the inside\nthe container, for example, for a container named `postgresql`:\n\n```\n$ docker exec -t -i postgresql /bin/bash\n$ psql -U postgres postgres\n```\n\nYou can create users:\n\n```\n$ createuser -U postgres -DRS -PE \u003cUSERNAME\u003e\n```\n\nYou can create a database:\n\n```\n$ createdb -U postgres -O \u003cUSERNAME\u003e \u003cDBNAME\u003e\n```\n\nYou can install PostGIS into your database by connecting to it and running:\n\n```\n\u003e CREATE EXTENSION postgis;\n```\n\nYou can backup a database from outside the container:\n\n```\n$ docker exec postgresql pg_dump -Fc -U postgres \u003cDBNAME\u003e \u003e /var/backups/\u003cDBNAME\u003e.pgdump\n```\n\nYou can restore a database from outside the container:\n\n```\n$ cat /var/backups/\u003cDBNAME\u003e.pgdump | docker exec -i postgresql pg_restore -Fc -U postgres -d \u003cDBNAME\u003e\n```\n\n### Single user\n\nWhen data volume is initialized at the first startup, you can instruct the image to\nautomatically create an user and/or a database by passing environment variables to a\ncontainer.\n\n## GitHub mirror\n\nThere is also a [read-only GitHub mirror available](https://github.com/tozd/docker-postgresql),\nif you need to fork the project there.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftozd%2Fdocker-postgresql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftozd%2Fdocker-postgresql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftozd%2Fdocker-postgresql/lists"}