postgres
An used for web applications, data analytics platforms, and enterprise systems.
What is postgre?
The postgres image runs PostgreSQL, a powerful open-source relational database system known for its reliability, SQL compliance, and extensibility. PostgreSQL supports advanced database features such as ACID transactions, JSONB storage, window functions, full-text search, and rich indexing capabilities. It’s widely used in production environments for web applications, data analytics platforms, and enterprise systems.
This image provides a fully functional PostgreSQL server in a containerized format, making it easy to run databases in local development, CI/CD pipelines, and Kubernetes clusters. PostgreSQL is often chosen in containerized infrastructure for its balance of strong relational guarantees and modern extensibility, supporting both structured and semi-structured data.
The postgres image is relevant for teams looking to deploy a reliable database service with predictable behavior, whether as a standalone container, part of a microservices architecture, or as a stateful service in orchestrated environments.
How to use this image
The postgres image can be run as a single-node database for testing or development, or extended into a production service with persistence and replication. It supports environment variables for configuring the database name, user, and password.Run a database container:docker run --name some-postgres -e POSTGRES_PASSWORD=mysecret -d postgres
Mount a persistent volume:
<code>docker run --name some-postgres -e POSTGRES_PASSWORD=mysecret \ -v pgdata:/var/lib/postgresql/data -d postgres</code>
Connect with psql client:
<code>docker exec -it some-postgres psql -U postgres</code>
Use as a base image in a Dockerfile:
<code>FROM postgres:16COPY init.sql /docker-entrypoint-initdb.d/</code>
By default, PostgreSQL listens on port 5432
. Logs are written to stdout
, viewable via docker logs
. Initialization scripts placed in /docker-entrypoint-initdb.d/
are executed when the container first starts.
{{cta}}
Image variants
ublished under postgres, the image is available in multiple variants:
postgres:latest
Tracks the latest stable release.Suitable for quick testing, but not recommended in production.
postgres:<version>
Tagged by release version (e.g. 16
, 15
, 14
).
Recommended for production to ensure stability and compatibility.
postgres:<version>-alpine
Lightweight Alpine-based variant.Significantly smaller footprint, but may lack some OS libraries required by extensions.
postgres:<version>-bullseye / -bookworm
Debian-based variants tied to specific distributions.Useful when aligning with enterprise baselines.Postgres images are regularly rebuilt to include security patches. For predictable deployments, pin to a specific tag like postgres:16.3
.