PostgreSQL Docker image with RDKit cartridge.
6.2K
A PostgreSQL 16 Docker image with the RDKit cartridge pre-installed and optimized for chemical informatics workloads.
This image inherits from the official postgres image, and therefore has all the same environment variables for configuration, and can be extended by adding entrypoint scripts to the /docker-entrypoint-initdb.d directory to be run on first launch.
postgresql.conf with RDKit-optimized settingsPull and run the image:
docker run -d \
--name postgres-rdkit \
-e POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password \
-e POSTGRES_USER=postgres \
-e POSTGRES_DB=mydb \
-p 5432:5432 \
iskoldt/postgres16-rdkit:latest
Or use Docker Compose:
services:
db:
image: iskoldt/postgres16-rdkit:latest
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_DB: mydb
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets:
- postgres_password
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
volumes:
postgres_data:
secrets:
postgres_password:
external: true
Start PostgreSQL with RDKit support:
docker run -d \
--name postgres-rdkit \
-e POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password \
-p 5432:5432 \
iskoldt/postgres16-rdkit:latest
Important: Never hardcode passwords in command lines or Docker Compose files. Use one of these secure methods:
Docker Secrets (recommended for Docker Swarm or Docker Compose):
echo "your-secure-password" | docker secret create postgres_password -
Environment Files:
docker run -d \
--name postgres-rdkit \
--env-file .env \
-p 5432:5432 \
iskoldt/postgres16-rdkit:latest
Where .env contains:
POSTGRES_PASSWORD=your-secure-password
Environment Variables (for development only):
export POSTGRES_PASSWORD="your-secure-password"
docker run -d \
--name postgres-rdkit \
-e POSTGRES_PASSWORD \
-p 5432:5432 \
iskoldt/postgres16-rdkit:latest
services:
db:
image: iskoldt/postgres16-rdkit:latest
restart: always
environment:
POSTGRES_USER: postgres
POSTGRES_DB: mydb
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
secrets:
- postgres_password
volumes:
- postgres_data:/var/lib/postgresql/data
ports:
- "5432:5432"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres"]
interval: 10s
timeout: 5s
retries: 5
volumes:
postgres_data:
secrets:
postgres_password:
file: ./secrets/postgres_password.txt
This image exposes port 5432 (the postgres port), so standard container linking will make it automatically available to the linked containers.
POSTGRES_PASSWORD: Superuser password for PostgreSQL (use POSTGRES_PASSWORD_FILE for secrets instead).POSTGRES_USER: Superuser username (default postgres).POSTGRES_DB: Default database that is created when the image is first started.PGDATA: Location for the database files (default /var/lib/postgresql/data).See the official postgres image for more details.
Images are automatically built and published to Docker Hub via GitHub Actions when:
main branchThe build process:
latest and date-based versions (YYYY.MM.DD format)iskoldt/postgres16-rdkitSee .github/workflows/build_multi_arch.yml for the build configuration.
To build the image manually:
docker build -t iskoldt/postgres16-rdkit:latest .
The Dockerfile uses a multi-stage build:
postgres:16-bookwormBuild arguments:
RDKIT_VERSION: RDKit version to build (default: Release_2025_03_1)Example with custom RDKit version:
docker build \
--build-arg RDKIT_VERSION=Release_2024_09_2 \
-t iskoldt/postgres16-rdkit:custom .
The image includes a pre-configured postgresql.conf optimized for RDKit workloads. Key settings include:
Note: The default configuration is tuned for a high-performance workstation (e.g., Apple M2 Max, Oracle Cloud ARM) with ~10-12GB RAM available. If running on a smaller instance (e.g., 2GB RAM), you MUST override
shared_buffersandwork_memvia command line flags or a custom config file to avoid OOM crashes.
shared_buffers = 2560MB: 25% of 10GB container RAMeffective_cache_size = 7GB: ~70% of 10GB container RAMwork_mem = 64MB: Per-query memory limitmaintenance_work_mem = 512MB: For vacuum and index creationrandom_page_cost = 1.1: Optimized for NVMe SSDeffective_io_concurrency = 200: High concurrency for NVMemin_wal_size = 1GB: Reduce checkpoint frequencymax_wal_size = 4GB: Limit WAL disk usagecheckpoint_completion_target = 0.9: Spread checkpoint I/O loadmax_worker_processes = 10: Allow background workers + parallel queriesmax_parallel_workers = 8: Utilize performance coresmax_parallel_workers_per_gather = 4: Limit parallel workers per querymax_connections = 200: Support expected concurrent userssynchronous_commit = on: Ensure data durabilityfull_page_writes = on: Protect against partial page writeslisten_addresses = '*': Listen on all interfacesTo use your own postgresql.conf:
docker run -d \
--name postgres-rdkit \
-v /path/to/custom/postgresql.conf:/etc/postgresql/postgresql.conf \
-e POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password \
iskoldt/postgres16-rdkit:latest \
postgres -c config_file=/etc/postgresql/postgresql.conf
The included postgresql.conf is already optimized for RDKit workloads. However, if you need to further optimize for specific use cases:
If you're doing bulk inserts and building indexes, you can temporarily adjust these settings (at the cost of data safety):
-- WARNING: These settings reduce data safety
ALTER SYSTEM SET synchronous_commit = 'off';
ALTER SYSTEM SET full_page_writes = 'off';
SELECT pg_reload_conf();
Warning:
synchronous_commit = off: Speeds normal operation but increases the chance of losing commits if PostgreSQL crashes. Commits will be reported as executed even if not stored and flushed to durable storage.full_page_writes = off: Speeds normal operation but might lead to unrecoverable or silent data corruption after a system failure.Recommendation: Only use these settings during initial data loading. To revert to production safety:
-- Revert to safe production defaults
ALTER SYSTEM RESET synchronous_commit;
ALTER SYSTEM RESET full_page_writes;
SELECT pg_reload_conf();
The default configuration already includes optimized memory settings:
shared_buffers = 2560MB: PostgreSQL's dedicated RAMwork_mem = 64MB: Maximum RAM per query operation before using diskThese settings increase the RAM requirements for PostgreSQL. Ensure your container has sufficient memory allocated.
Source: RDKit Cartridge Configuration
For more information, see the RDKit PostgreSQL Cartridge documentation.
postgres:16-bookwormSee LICENSE file for details.
Content type
Image
Digest
sha256:42202485f…
Size
254.7 MB
Last updated
6 months ago
docker pull iskoldt/postgres16-rdkit