The World's Most Advanced Open Source Relational Database on FreeBSD.
| Port | 5432 |
| Registry | ghcr.io/daemonless/postgres |
| Source | https://www.postgresql.org/ |
| Website | https://www.postgresql.org/ |
| Tag | Description | Best For |
|---|---|---|
14 / 14-pkg-latest |
FreeBSD Latest. Rolling package updates. | Staying current. |
15 / 15-pkg-latest |
FreeBSD Latest. Rolling package updates. | Staying current. |
16 / 16-pkg-latest |
FreeBSD Latest. Rolling package updates. | Staying current. |
17 / 17-pkg-latest |
FreeBSD Latest. Rolling package updates. | Staying current. |
18 / 18-pkg-latest / latest / pkg / pkg-latest |
FreeBSD Latest. Rolling package updates. | Staying current. |
Before deploying, ensure your host environment is ready. See the Quick Start Guide for host setup instructions.
services:
postgres:
image: "ghcr.io/daemonless/postgres:latest"
container_name: postgres
environment:
- POSTGRES_USER=postgres # Database superuser name (default: postgres)
- POSTGRES_PASSWORD=postgres # Database superuser password
- POSTGRES_DB=postgres # Default database to create (default: same as user)
- PUID=1000
- PGID=1000
- TZ=UTC
- POSTGRES_INITDB_ARGS= # Additional arguments for initdb
- POSTGRES_HOST_AUTH_METHOD= # Authentication method (default: scram-sha-256)
volumes:
- "/path/to/containers/postgres:/var/lib/postgresql/data"
ports:
- "5432:5432"
annotations:
org.freebsd.jail.allow.sysvipc: "true"
# always (not unless-stopped) so FreeBSD's podman rc.d auto-starts it at boot
restart: alwaysSave as compose.yaml, then run podman-compose up -d.
.env:
# .env
DIRECTOR_PROJECT=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=postgres
PUID=1000
PGID=1000
TZ=UTC
POSTGRES_INITDB_ARGS=
POSTGRES_HOST_AUTH_METHOD=
appjail-director.yml:
# appjail-director.yml
options:
- virtualnet: ':<random> default'
- nat:
services:
postgres:
name: postgres
options:
- container: 'args:--pull'
- expose: '5432:5432 proto:tcp'
- template: !ENV '${PWD}/template.conf'
oci:
user: root
environment:
- POSTGRES_USER: !ENV '${POSTGRES_USER}'
- POSTGRES_PASSWORD: !ENV '${POSTGRES_PASSWORD}'
- POSTGRES_DB: !ENV '${POSTGRES_DB}'
- PUID: !ENV '${PUID}'
- PGID: !ENV '${PGID}'
- TZ: !ENV '${TZ}'
- POSTGRES_INITDB_ARGS: !ENV '${POSTGRES_INITDB_ARGS}'
- POSTGRES_HOST_AUTH_METHOD: !ENV '${POSTGRES_HOST_AUTH_METHOD}'
volumes:
- postgres: /var/lib/postgresql/data
volumes:
postgres:
device: '/path/to/containers/postgres'Makejail:
# Makejail
ARG tag=latest
OPTION container=boot
OPTION overwrite=force
OPTION from=ghcr.io/daemonless/postgres:${tag}
template.conf:
# template.conf
exec.start: "/bin/sh /etc/rc"
exec.stop: "/bin/sh /etc/rc.shutdown jail"
mount.devfs
persist
allow.sysvipc
Save the files above, then run appjail-director up.
Warning
Exposing ports in AppJail means that your service can be reached from remote hosts. If that is not your intention, do not expose the ports and communicate with the service using the jail's IPv4 address or hostname assigned by the virtual network.
To avoid exposing ports, just remove the expose option in your appjail-director.yml or from your command-line arguments.
podman run -d --name postgres \
-p 5432:5432 \
--annotation 'org.freebsd.jail.allow.sysvipc=true' \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=UTC \
-e POSTGRES_INITDB_ARGS= \
-e POSTGRES_HOST_AUTH_METHOD= \
-v /path/to/containers/postgres:/var/lib/postgresql/data \
ghcr.io/daemonless/postgres:latestSave as run.sh, then run sh run.sh.
appjail oci run -Pd \
-o overwrite=force \
-o container="args:--pull" \
-o virtualnet=":<random> default" \
-o nat \
-o template=template.conf \
-o expose="5432:5432 proto:tcp" \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_DB=postgres \
-e PUID=1000 \
-e PGID=1000 \
-e TZ=UTC \
-e POSTGRES_INITDB_ARGS= \
-e POSTGRES_HOST_AUTH_METHOD= \
-o fstab="/path/to/containers/postgres /var/lib/postgresql/data <pseudofs>" \
ghcr.io/daemonless/postgres:latest postgrestemplate.conf:
# template.conf
exec.start: "/bin/sh /etc/rc"
exec.stop: "/bin/sh /etc/rc.shutdown jail"
mount.devfs
persist
allow.sysvipc
Save the files above, then run sh run.sh.
Warning
Exposing ports in AppJail means that your service can be reached from remote hosts. If that is not your intention, do not expose the ports and communicate with the service using the jail's IPv4 address or hostname assigned by the virtual network.
To avoid exposing ports, just remove the expose option in your appjail-director.yml or from your command-line arguments.
Warning
Bastille's OCI support is experimental. It requires buildah and shares the host network stack (inherit). Mount volumes with --volume HOST JAIL; without it, image-declared volumes are stored under ${bastille_volumesdir}/${jail}.
services:
postgres:
name: postgres
image: "ghcr.io/daemonless/postgres:latest"
network:
- mode: host
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- POSTGRES_DB=postgres
- PUID=1000
- PGID=1000
- TZ=UTC
- POSTGRES_INITDB_ARGS=
- POSTGRES_HOST_AUTH_METHOD=
volumes:
- "/path/to/containers/postgres:/var/lib/postgresql/data"Save as bastille-compose.yml, then run bastille up. Or via CLI:
bastille create -O \
--env POSTGRES_USER=postgres \
--env POSTGRES_PASSWORD=postgres \
--env POSTGRES_DB=postgres \
--env PUID=1000 \
--env PGID=1000 \
--env TZ=UTC \
--env POSTGRES_INITDB_ARGS= \
--env POSTGRES_HOST_AUTH_METHOD= \
--volume /path/to/containers/postgres /var/lib/postgresql/data \
postgres ghcr.io/daemonless/postgres:latest inherit- name: Deploy postgres
containers.podman.podman_container:
name: postgres
image: "ghcr.io/daemonless/postgres:latest"
state: started
restart_policy: always
env:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_DB: "postgres"
PUID: "1000"
PGID: "1000"
TZ: "UTC"
POSTGRES_INITDB_ARGS: ""
POSTGRES_HOST_AUTH_METHOD: ""
ports:
- "5432:5432"
volumes:
- "/path/to/containers/postgres:/var/lib/postgresql/data"
annotation:
org.freebsd.jail.allow.sysvipc: "true"Save as postgres-deploy.yaml, then run ansible-playbook postgres-deploy.yaml.
| Variable | Default | Description |
|---|---|---|
POSTGRES_USER |
postgres |
Database superuser name (default: postgres) |
POSTGRES_PASSWORD |
postgres |
Database superuser password |
POSTGRES_DB |
postgres |
Default database to create (default: same as user) |
PUID |
1000 |
|
PGID |
1000 |
|
TZ |
UTC |
|
POSTGRES_INITDB_ARGS |
`` | Additional arguments for initdb |
POSTGRES_HOST_AUTH_METHOD |
`` | Authentication method (default: scram-sha-256) |
| Path | Description |
|---|---|
/var/lib/postgresql/data |
Database data directory |
| Port | Protocol | Description |
|---|---|---|
5432 |
TCP | PostgreSQL port |
Architectures: amd64, aarch64
User: bsd (UID/GID via PUID/PGID, defaults to 1000:1000)
Base: FreeBSD 15.1
Need help? Join our Discord community.