Hardened official PostgreSQL images with gosu replaced by su-exec
9.7K
Hardened PostgreSQL container images built on top of the official Debian stable release, featuring automated upstream security updates, jemalloc memory allocator, built-in HEALTHCHECK, standardized RHEL-compatible UID/GID (26:26), and gosu replaced by su-exec.
gosu replaced by a lightweight, compiled-from-source su-exec.apt, dpkg), network transfer tools (curl, wget, nc), man pages, and residual SUID/SGID binaries stripped from the final image./usr/sbin/nologin) and locked local account passwords.HOME=/tmp and directory permissions ready for read-only root filesystems (read_only: true), cap_drop: [ALL], and arbitrary --user overrides.libjemalloc2 preloaded via LD_PRELOAD (architecture-agnostic for linux/amd64 and linux/arm64).HEALTHCHECK using pg_isready out of the box (unlike the upstream official image).postgres user/group standardized to UID/GID 26 for seamless volume permissions across RHEL, RockyLinux, AlmaLinux, and Fedora hosts.en_US.UTF-8 locale pre-configured.postgresql.org in ascending build order.Note: Unlike the upstream image (which uses UID
999and versionedPGDATApaths starting in PostgreSQL 18),infra7/postgresstandardizes thepostgresuser to UID/GID26:26and keepsPGDATA=/var/lib/postgresql/dataacross all versions for consistent volume mounting.
The Makefile supports Docker (buildx), Podman, and Buildah:
# Check detected PostgreSQL active releases and build order
make info
# Build all active versions locally (native architecture) using Docker
make
# Build a specific subset of major versions
make skip-build="15 16 17 18"
# Build using Podman or Buildah
make engine=podman
make engine=buildah
# Specific-arch / Multi-arch build (linux/amd64, linux/arm64, etc)
make repo=local platform=linux/amd64
Compatible with both docker compose and podman compose. Create the required secret files first:
mkdir -p secrets
echo "postgres" > secrets/postgres.user
openssl rand -base64 24 > secrets/postgres.pass
chmod 600 secrets/*
Start the container:
docker compose up -d
# or
podman compose up -d
For general PostgreSQL environment variables and initialization behavior, refer to the official PostgreSQL Docker documentation.
This project is licensed under the MIT License — see the LICENSE file for details.
The Infra7 name and brand remain the exclusive property of their respective owners and may not be used to endorse derived images without prior permission.
Content type
Image
Digest
sha256:e5315398c…
Size
160.4 MB
Last updated
1 day ago
docker pull infra7/postgres