I have a postgresql database running inside a docker container and want to debug functions on that database using pgAdmin. Doing that on my local postgres installation presents no issue when following the official guidelines. However, I am running into an issue when trying the same thing with the database inside the docker container.
To debug, I need this line: shared_preload_libraries = '$libdir/plugin_debugger.dll'
in my postgresql.conf
file.
Editing the file in the docker container is easy enough, but when I do so and try to restart the container, it presents me with this message:
FATAL: could not access file "$libdir/plugin_debugger.so": No such file or directory
I tried following this gist, however, when git clone git://git.postgresql.org/git/pldebugger.git
gets executed I am presented with the following message
fatal: remote error: access denied or repository not exported: /git/pldebugger.git
I'm using the official postgres:latest
image. Does anyone know I can do this?
🗎 Dockerfile
(This will install the required dependencies and then build the extension from source.)
FROM postgres:16.0
ENV POSTGRES_DB ""
ENV POSTGRES_USER ""
ENV POSTGRES_PASSWORD ""
RUN apt-get update -q && \
apt-get install -q -y git make gcc libkrb5-dev postgresql-server-dev-16
WORKDIR /usr/share/postgresql/16/contrib
ENV USE_PGXS=1
RUN git clone https://github.com/EnterpriseDB/pldebugger.git && \
cd pldebugger && \
make
COPY setup-pg-admin.sh /docker-entrypoint-initdb.d/
🗎 setup-pg-admin.sh
(This will ensure that the extension is loaded when the database starts.)
#!/bin/bash
cat <<EOT >> /var/lib/postgresql/data/postgresql.conf
shared_preload_libraries='/usr/share/postgresql/16/contrib/pldebugger/plugin_debugger.so'
EOT
🗎 docker-compose.yml
(This is not strictly necessary, but it shows how to launch PostgreSQL with the required environment variables etc.)
version: '3'
services:
data-pipeline-db:
image: data-pipeline-db
restart: always
container_name: data-pipeline-db
shm_size: 512mb
build:
context: .
dockerfile: ./Dockerfile
environment:
- POSTGRES_DB=testing
- POSTGRES_USER=test
- POSTGRES_PASSWORD=test