Sign inSign up

andreidrang/postgreslite

By andreidrang

•Updated 3 months ago

postgreslite

Image
Databases & storage
0

1.1K

andreidrang/postgreslite repository overview

⁠PostgreSQL Lite

Docker Pulls Docker Image Size

A lightweight, optimized PostgreSQL Docker image based on PostgreSQL 17.7, pre-configured for small projects with resource-efficient settings and built-in query performance monitoring.

⁠Features

  • Optimized for small projects: Reduced connection limits and memory settings suitable for development and small production deployments
  • Performance monitoring: pg_stat_statements extension pre-enabled for query performance tracking
  • SSD-optimized: Tuned I/O settings for modern SSD storage
  • Security: SCRAM-SHA-256 password encryption enabled by default
  • UTC timezone: Configured for consistent time handling across environments
  • Production-ready: Based on official PostgreSQL 17.7 image

⁠Quick Start

⁠Docker Run
docker run -d \
  --name postgres-lite \
  -e POSTGRES_USER=postgres \
  -e POSTGRES_PASSWORD=yourpassword \
  -e POSTGRES_DB=mydb \
  -p 5432:5432 \
  andreidrang/postgreslite
⁠Docker Compose
version: '3.8'

services:
  db:
    image: andreidrang/postgreslite
    container_name: postgres-lite
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=yourpassword
      - POSTGRES_DB=mydb
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data/pgdata
    restart: unless-stopped

volumes:
  postgres_data:

⁠Configuration Summary

This image uses a custom PostgreSQL configuration optimized for small projects. Key settings include:

⁠Connections
  • max_connections: 60 (optimized for small deployments)
  • listen_addresses: '*' (accepts connections from all interfaces)
⁠Memory Settings
  • shared_buffers: 256MB
  • work_mem: 3855kB (~3.8MB)
  • maintenance_work_mem: 64MB
  • effective_cache_size: 768MB
⁠Performance Tuning
  • effective_io_concurrency: 300 (optimized for SSD)
  • random_page_cost: 1.1 (SSD-optimized)
  • default_statistics_target: 100
  • max_worker_processes: 8
  • max_parallel_workers: 2
  • max_parallel_workers_per_gather: 2
⁠Write-Ahead Log (WAL)
  • wal_buffers: 7864kB (~7.7MB)
  • max_wal_size: 8GB
  • min_wal_size: 2GB
  • checkpoint_completion_target: 0.9
⁠Monitoring
  • pg_stat_statements: Enabled
    • max: 10,000 queries tracked
    • track: all (DDL, DML, and utility statements)
  • compute_query_id: on
⁠Security
  • password_encryption: scram-sha-256
  • scram_iterations: 4096
⁠Locale & Timezone
  • timezone: Etc/UTC
  • log_timezone: Etc/UTC
  • datestyle: iso, mdy
  • locale: en_US.utf8 (messages, monetary, numeric, time)

⁠Environment Variables

The image supports all standard PostgreSQL environment variables:

  • POSTGRES_USER: Database superuser (default: postgres)
  • POSTGRES_PASSWORD: Password for the superuser (required)
  • POSTGRES_DB: Initial database name (default: same as POSTGRES_USER)
  • POSTGRES_INITDB_ARGS: Additional arguments for initdb
  • PGDATA: Data directory (default: /var/lib/postgresql/data/pgdata)

⁠Configuration File

The custom configuration file is located at /etc/postgresql.conf inside the container. The image automatically uses this configuration on startup.

To view the current configuration:

docker exec postgres-lite cat /etc/postgresql.conf

⁠Query Performance Monitoring

The pg_stat_statements extension is pre-enabled. To view query statistics:

-- Connect to your database
psql -U postgres -d mydb

-- Enable the extension (if not already enabled)
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;

-- View top queries by total execution time
SELECT 
    query,
    calls,
    total_exec_time,
    mean_exec_time,
    max_exec_time
FROM pg_stat_statements
ORDER BY total_exec_time DESC
LIMIT 10;

⁠Base Image

  • PostgreSQL: 17.7
  • Source: Official postgres⁠ Docker image

⁠Use Cases

This image is ideal for:

  • Development environments
  • Small production deployments
  • Microservices with lightweight database needs
  • CI/CD pipelines
  • Prototyping and testing

⁠Resource Requirements

Recommended minimum resources:

  • CPU: 1 core
  • Memory: 512MB - 1GB
  • Disk: 10GB+ (depending on data size)

⁠License

This image is based on the official PostgreSQL Docker image, which uses the PostgreSQL License (similar to BSD/MIT).

⁠Support

For issues, questions, or contributions, please visit the GitHub repository⁠.

⁠Version

  • Image: andreidrang/postgreslite
  • PostgreSQL: 17.7
  • Config: Optimized for small projects

Tag summary

Content type

Image

Digest

sha256:dfb0c6e72…

Size

172.4 MB

Last updated

3 months ago

docker pull andreidrang/postgreslite:18.4