citusdata / citusdata/pg_cron

Problem when installing pg_cron. Can you help me fix my Dockerfile?

Open
#304 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
3.9k
Forks
260
Avg merge
5d 5h
Merged PRs (30d)
1

Description

I know this is a very common error when installing pg_cron but I cannot make it work even after reading.

i get this error when i run "CREATE EXTENSION pg_cron;"

ERROR: unrecognized configuration parameter "cron.database_name"
CONTEXT: PL/pgSQL function inline_code_block line 3 at IF

SQL state: 42704

my Dockerfile looks like this (i created an image of postgres with postgis, pgvector and cron all extensions work bu cron).

`
FROM postgres:15

ENV POSTGRES_DB mydatabase
ENV POSTGRES_USER myuser
ENV POSTGRES_PASSWORD mypassword

# Update package lists
RUN apt-get update

# Install PostgreSQL extensions
RUN apt-get install -y --no-install-recommends \
postgresql-contrib \
postgresql-15-pgvector \
postgresql-15-cron \
postgresql-15-postgis

# Create a custom configuration file
RUN mkdir -p /var/lib/postgresql/data/conf.d \
&& echo "shared_preload_libraries = 'pg_cron'" > /var/lib/postgresql/data/conf.d/pg_cron.conf \
&& echo "cron.database_name = 'mydatabase'" >> /var/lib/postgresql/data/conf.d/pg_cron.conf \
&& chown -R postgres:postgres /var/lib/postgresql/data/conf.d

# Include the custom configuration file
RUN echo "include_dir = '/var/lib/postgresql/data/conf.d'" >> /var/lib/postgresql/data/postgresql.conf

# Clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Expose the PostgreSQL port
EXPOSE 5432
`

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the Dockerfile configuration for shared_preload_libraries, cron.database_name, and the postgresql.conf include_dir shown in the issue. Reproduce the image and inspect the running PostgreSQL configuration before running CREATE EXTENSION pg_cron. Done means the cron.database_name parameter is recognized and the extension can be created successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, postgresql
Domain
databases, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.