|
| 1 | +# PostgreSQL |
| 2 | + |
| 3 | +PostgreSQL database server on FreeBSD. |
| 4 | + |
| 5 | +## Quick Start |
| 6 | + |
| 7 | +```bash |
| 8 | +podman run -d --name postgres \ |
| 9 | + -p 5432:5432 \ |
| 10 | + -e POSTGRES_PASSWORD=mysecretpassword \ |
| 11 | + -v /path/to/data:/var/db/postgres \ |
| 12 | + --annotation 'org.freebsd.jail.allow.sysvipc=true' \ |
| 13 | + ghcr.io/daemonless/postgres:17 |
| 14 | +``` |
| 15 | + |
| 16 | +## podman-compose |
| 17 | + |
| 18 | +```yaml |
| 19 | +services: |
| 20 | + postgres: |
| 21 | + image: ghcr.io/daemonless/postgres:17 |
| 22 | + container_name: postgres |
| 23 | + environment: |
| 24 | + - POSTGRES_USER=postgres |
| 25 | + - POSTGRES_PASSWORD=mysecretpassword |
| 26 | + - POSTGRES_DB=mydb |
| 27 | + volumes: |
| 28 | + - /data/postgres:/var/db/postgres |
| 29 | + ports: |
| 30 | + - 5432:5432 |
| 31 | + annotations: |
| 32 | + org.freebsd.jail.allow.sysvipc: "true" |
| 33 | + restart: unless-stopped |
| 34 | +``` |
| 35 | +
|
| 36 | +## Tags |
| 37 | +
|
| 38 | +| Tag | Description | |
| 39 | +|-----|-------------| |
| 40 | +| `:17` | PostgreSQL 17 (latest) | |
| 41 | +| `:14` | PostgreSQL 14 | |
| 42 | +| `:latest` | Alias for `:17` | |
| 43 | + |
| 44 | +## Environment Variables |
| 45 | + |
| 46 | +| Variable | Default | Description | |
| 47 | +|----------|---------|-------------| |
| 48 | +| `POSTGRES_USER` | `postgres` | Database superuser name | |
| 49 | +| `POSTGRES_PASSWORD` | (empty) | Superuser password | |
| 50 | +| `POSTGRES_DB` | `postgres` | Default database name | |
| 51 | +| `PGDATA` | `/var/db/postgres/dataXX` | Data directory (XX = version) | |
| 52 | +| `POSTGRES_INITDB_ARGS` | (empty) | Extra args for initdb (e.g., `--data-checksums`) | |
| 53 | +| `POSTGRES_HOST_AUTH_METHOD` | `scram-sha-256` | Auth method (`scram-sha-256`, `md5`, `trust`) | |
| 54 | + |
| 55 | +### Docker Secrets |
| 56 | + |
| 57 | +Secrets can be passed via `*_FILE` environment variables: |
| 58 | + |
| 59 | +| Variable | Description | |
| 60 | +|----------|-------------| |
| 61 | +| `POSTGRES_PASSWORD_FILE` | Path to file containing password | |
| 62 | + |
| 63 | +## Initialization Scripts |
| 64 | + |
| 65 | +Place scripts in `/docker-entrypoint-initdb.d/` to run on first startup: |
| 66 | + |
| 67 | +| Extension | Behavior | |
| 68 | +|-----------|----------| |
| 69 | +| `*.sh` | Executed if executable, sourced otherwise | |
| 70 | +| `*.sql` | Run via psql against `$POSTGRES_DB` | |
| 71 | +| `*.sql.gz` | Decompressed and run via psql | |
| 72 | + |
| 73 | +Scripts run in sorted filename order after database creation. |
| 74 | + |
| 75 | +## Volumes |
| 76 | + |
| 77 | +| Path | Description | |
| 78 | +|------|-------------| |
| 79 | +| `/var/db/postgres` | PostgreSQL data directory | |
| 80 | + |
| 81 | +## Ports |
| 82 | + |
| 83 | +| Port | Description | |
| 84 | +|------|-------------| |
| 85 | +| 5432 | PostgreSQL | |
| 86 | + |
| 87 | +## Notes |
| 88 | + |
| 89 | +- **User:** `bsd` (UID/GID 1000) |
| 90 | +- **SysV IPC:** Requires `--annotation 'org.freebsd.jail.allow.sysvipc=true'` |
| 91 | + |
| 92 | +## Links |
| 93 | + |
| 94 | +- [PostgreSQL Website](https://www.postgresql.org/) |
| 95 | +- [FreshPorts postgresql17-server](https://www.freshports.org/databases/postgresql17-server/) |
| 96 | +- [FreshPorts postgresql14-server](https://www.freshports.org/databases/postgresql14-server/) |
0 commit comments