Pgpool-II Docker image with full environment variable-based configurations. Based on Bitnami Pgpool.
1.0K
This Docker image is based on bitnami/pgpool:latest and is tailored for a specific use case: providing full pgpool configuration through environment variables to simplify deployment without mounting configuration files.
It is designed primarily for scenarios where you use cloud-hosted PostgreSQL replicas and want lightweight load balancing in a single VM or serverless Docker environment, enabling quick, zero-config deployments.
While configuration files are commonly preferred for large-scale or Kubernetes-based deployments, this image focuses on simpler, cost-effective setupsβsuch as cloud-hosted PostgreSQL with replicasβwhere lightweight load balancing is needed using Docker in a single VM or serverless environment.
By relying entirely on environment variables, it enables fast deployment without volume mounts or custom templates. This approach works well for SaaS platforms, testing, minimal infrastructure, and also scales efficiently at low operational cost without the complexity of orchestration layers.
docker run -d \
--name pgpool \
-p 5432:5432 \
-e PGPOOL_BACKEND_NODES="0:postgres-master:5432:1,1:postgres-slave1:5432:2,2:postgres-slave2:5432:1" \
-e PGPOOL_SR_CHECK_USER=postgres \
-e PGPOOL_SR_CHECK_PASSWORD=password \
-e PGPOOL_POSTGRES_USERNAME=postgres \
-e PGPOOL_POSTGRES_PASSWORD=password \
-e PGPOOL_ADMIN_USERNAME=admin \
-e PGPOOL_ADMIN_PASSWORD=adminpass \
royprasun/pgpool:latest
docker run -d \
--name pgpool-ssl \
-p 5432:5432 \
-v /path/to/certs:/opt/bitnami/pgpool/certs \
-e PGPOOL_BACKEND_NODES="0:postgres-master:5432,1:postgres-slave:5432" \
-e PGPOOL_ENABLE_TLS=yes \
-e PGPOOL_TLS_CERT_FILE=/opt/bitnami/pgpool/certs/postgres.crt \
-e PGPOOL_TLS_KEY_FILE=/opt/bitnami/pgpool/certs/postgres.key \
-e PGPOOL_SR_CHECK_USER=postgres \
-e PGPOOL_SR_CHECK_PASSWORD=password \
royprasun/pgpool:latest
PGPOOL_BACKEND_NODES (Enhanced)Configure backend PostgreSQL nodes with optional load balancing weights.
Format: index:hostname:port[:weight][,index:hostname:port[:weight]]...
Examples:
# Basic configuration (weight defaults to 1)
PGPOOL_BACKEND_NODES="0:postgres-master:5432,1:postgres-slave:5432"
# With custom weights (slave gets 2x more read traffic)
PGPOOL_BACKEND_NODES="0:postgres-master:5432:1,1:postgres-slave:5432:2"
# Multiple backends with different weights
PGPOOL_BACKEND_NODES="0:master:5432:1,1:slave1:5432:3,2:slave2:5432:2,3:slave3:5432:1"
| Variable | Description | Default |
|---|---|---|
PGPOOL_LISTEN_ADDRESSES | IP addresses to listen on | * |
PGPOOL_PORT_NUMBER | Pgpool port number | 5432 |
PGPOOL_MAX_POOL | Max connection pool size per child | 15 |
PGPOOL_CHILD_LIFE_TIME | Child process lifetime (seconds) | 300 |
PGPOOL_CONNECTION_LIFE_TIME | Backend connection lifetime (seconds) | 0 |
PGPOOL_CLIENT_IDLE_LIMIT | Client idle timeout (seconds) | 0 |
| Variable | Description | Default |
|---|---|---|
PGPOOL_SR_CHECK_PERIOD | Streaming replication check interval | 30 |
PGPOOL_SR_CHECK_USER | User for SR checks | - |
PGPOOL_SR_CHECK_PASSWORD | Password for SR checks | - |
PGPOOL_SR_CHECK_DATABASE | Database for SR checks | postgres |
| Variable | Description | Default |
|---|---|---|
PGPOOL_HEALTH_CHECK_PERIOD | Health check interval (seconds) | 30 |
PGPOOL_HEALTH_CHECK_TIMEOUT | Health check timeout (seconds) | 10 |
PGPOOL_HEALTH_CHECK_USER | Health check user | - |
PGPOOL_HEALTH_CHECK_PASSWORD | Health check password | - |
PGPOOL_HEALTH_CHECK_MAX_RETRIES | Max retry attempts | 5 |
PGPOOL_HEALTH_CHECK_RETRY_DELAY | Retry delay (seconds) | 5 |
PGPOOL_CONNECT_TIMEOUT | Connection timeout (milliseconds) | 10000 |
| Variable | Description | Default |
|---|---|---|
PGPOOL_LOAD_BALANCE_MODE | Enable load balancing | on |
PGPOOL_DISABLE_LOAD_BALANCE_ON_WRITE | Load balance behavior after writes | transaction |
PGPOOL_STATEMENT_LEVEL_LOAD_BALANCE | Statement-level load balancing | off |
| Variable | Description | Default |
|---|---|---|
PGPOOL_FAILOVER_COMMAND | Command to execute on failover | echo ">>> Failover..." |
PGPOOL_FAILOVER_ON_BACKEND_ERROR | Failover on backend errors | off |
PGPOOL_FAILOVER_ON_BACKEND_SHUTDOWN | Failover on backend shutdown | on |
PGPOOL_SEARCH_PRIMARY_NODE_TIMEOUT | Primary search timeout | 0 |
| Variable | Description | Default |
|---|---|---|
PGPOOL_ENABLE_TLS | Enable SSL/TLS | no |
PGPOOL_TLS_CERT_FILE | Path to certificate file | - |
PGPOOL_TLS_KEY_FILE | Path to private key file | - |
PGPOOL_TLS_CA_FILE | Path to CA certificate file | - |
| Variable | Description | Default |
|---|---|---|
PGPOOL_LOG_CONNECTIONS | Log client connections | off |
PGPOOL_LOG_HOSTNAME | Log hostnames instead of IPs | off |
PGPOOL_LOG_PER_NODE_STATEMENT | Log statements per node | off |
| Variable | Description | Default |
|---|---|---|
PGPOOL_POSTGRES_USERNAME | PostgreSQL admin username | - |
PGPOOL_POSTGRES_PASSWORD | PostgreSQL admin password | - |
PGPOOL_ADMIN_USERNAME | Pgpool admin username | - |
PGPOOL_ADMIN_PASSWORD | Pgpool admin password | - |
All existing Bitnami pgpool environment variables are supported:
PGPOOL_ENABLE_LDAPPGPOOL_ENABLE_LOAD_BALANCINGPGPOOL_ENABLE_STATEMENT_LOAD_BALANCINGPGPOOL_ENABLE_POOL_HBAPGPOOL_ENABLE_POOL_PASSWDPGPOOL_NUM_INIT_CHILDRENPGPOOL_RESERVED_CONNECTIONSPGPOOL_POSTGRES_CUSTOM_USERSPGPOOL_POSTGRES_CUSTOM_PASSWORDSFor development, testing, or learning:
# Start simple setup with basic PostgreSQL instances
docker compose -f docker-compose-simple.yml up -d
For production deployments with streaming replication:
# Start production HA cluster
docker compose -f docker-compose-production.yml up -d
Perfect for development and testing. Uses basic PostgreSQL instances for quick validation of pgpool features.
Full production-ready setup with PostgreSQL streaming replication using bitnami/postgresql:16 for high availability and reliability.
Backend nodes not connecting
PGPOOL_BACKEND_NODES formatHealth checks failing
PGPOOL_HEALTH_CHECK_USER has proper permissionsLoad balancing not working
PGPOOL_LOAD_BALANCE_MODE=onView the generated configuration:
# Access the container
docker exec -it pgpool-debug bash
# View the generated pgpool.conf
cat /opt/bitnami/pgpool/conf/pgpool.conf
# Check pgpool status
pgpool -f /opt/bitnami/pgpool/conf/pgpool.conf -F /opt/bitnami/pgpool/conf/pcp.conf -n
The image includes built-in health checks:
# Manual health check
docker exec pgpool /opt/bitnami/scripts/pgpool/healthcheck.sh
Connect to pgpool and run monitoring queries:
-- Show pool nodes status
SHOW POOL_NODES;
-- Show pool processes
SHOW POOL_PROCESSES;
-- Show pool version
SHOW POOL_VERSION;
Content type
Image
Digest
sha256:edb9aa657β¦
Size
66.5 MB
Last updated
about 1 year ago
docker pull royprasun/pgpool