Sign inSign up

mich43l/postgresql

By mich43l

Updated 11 months ago

Postgres database server on docker

Image
Databases & storage
0

1.3K

mich43l/postgresql repository overview

PostgreSQL Docker Image

Docker Postgres imgsize dockerautomated

This repository contains the Dockerfile and resources to build a lightweight and efficient PostgreSQL container based on the latest Debian image. The container is designed to run PostgreSQL securely and flexibly, providing a robust foundation for database-driven applications.

Features

  • PostgreSQL Version: Configurable via build argument (PGSQL_VERSION), defaults to 17.
  • Lightweight Base: Built on the latest Debian base image for stability and security.
  • Locale Support: Supports configurable locale settings (LANG, CC, and ENCODING).
  • Custom Entrypoint: Includes a customizable docker-entrypoint.sh script for initialization.
  • Enhanced Security: Utilizes gosu to manage privilege escalation.
  • Persistent Data: Data volume mounted at /var/lib/postgresql/data for data persistence.
  • Dynamic Configuration: Configured to accept external connections by default (listen_addresses = '*').
  • Custom Initialization: Supports initialization scripts via /docker-entrypoint-initdb.d.

Volumes

  • /var/lib/postgresql/data: Directory to store database files.

Initialization Scripts

Place any .sql or .sh files into /docker-entrypoint-initdb.d to run during container initialization.

Security

This image incorporates best practices for security:

  • Runs PostgreSQL as a non-root user (postgres).
  • Leverages gosu for privilege escalation.
  • Prepares directories with strict permissions.

Build image

git clone https://github.com/mach1el/docker-library.git && \
  cd docker-library/postgresql && \
  docker buildx build --platform linux/amd64 build -t postgresql .
docker build --build-arg PGSQL_VERSION=17 -t mich43l/postgresql .

Build with arguments

Variables

Build argument
VariablesDefaultDescription
PGSQL_VERSION17Default postgresql version.
CCen_USSpecifies the input source file for locale definitions.
LANGen_US.UTF-8Specifies the name of the locale to generate.
ENCODINGUTF-8Specifies the character encoding file to use for the locale.
Run environment
VariablesDefaultDescription
CCen_USSpecifies the input source file for locale definitions.
LANGen_US.UTF-8Specifies the name of the locale to generate.
ENCODINGUTF-8Specifies the character encoding file to use for the locale.
POSTGRES_DBpostgreSpecify name for database.
POSTGRES_USERpostgreUse other username instead of postgres.
POSTGRES_PASSWORDpostgreChange default postgres password.
POSTGRES_LOG_STATEMENTallSpecify postgres log statment mode.

Run

docker run -d \
  --name postgresql \
  -e POSTGRES_USER=youruser \
  -e POSTGRES_PASSWORD=yourpassword \
  -e POSTGRES_DB=yourdatabase \
  -v /path/to/data:/var/lib/postgresql/data \
  -p 5432:5432 \
  mich43l/postgresql

Tag summary

Content type

Image

Digest

sha256:d196761ee

Size

188.7 MB

Last updated

almost 2 years ago

docker pull mich43l/postgresql